星☆空 | 对生活要知足,学习要不知足,为人处事要知不足. 卍 ♂ | ♀ 卐 - 科技以人为本.

QQ:908202921, Msn:btbtd@live.com gI.2288.oRg:88 绿色学院 - GrEeN InsTiTutE, www.btbtd.org

用户操作
[即时聊天] [发私信] [加为好友]
邱少伟ID:btbtd
405135次访问,排名124好友172人,关注者170
韬光养晦
http://www.btbtd.org/
http://gi.2288.org/
shawl.qiu,CSharp,DotNet,个人资料管理系统
btbtd的文章
原创 429 篇
翻译 3 篇
转载 16 篇
评论 370 篇
shawl.qiu的公告
www.btbtd.org
gi.2288.org
最近评论
zxc:shanghai hotel
guangzhou hotel
Gucci shoes Gucci Handbag adidas shoes
tungsten carbide thermoforming machine flexible ……
asdf:
tungsten carbide thermoforming machine flexible ……
ffff:tungsten carbidethermoforming machine flexible connectors 包装机械 印刷机械 bag making machine 包装机 jordan shoes prada shoes Gucci shoes adidas shoes nike shoes ugg boots evisu jeans true religion jeans Guc……
文章分类
收藏
相册
#蔡淳佳
#实用素材图片 1
#实用素材图片 2
#喜欢的作品
#资料截图
Aselin Debison
Avatar
Background
Blog
Concept
Diary
Doodle
Doodle 2005
Enigma
excite jp
fresh flowers
Google
Guestbook
Logo
Matter
Me
MSN
Music Cover
My Album
My Desktop
Opera
Oracle
OragTiger
PP Photo
Search
Signature
Sophie Zelmani
VMWARE
Wallpaper
wwy
wwy_baby_blue
wwy_my_room
wwy_stone_beige
Xoops
Xoops Newbb
Xoops Themes
Xoops Xphpbbi
YiMengCz I
#1. Algorithm
Bit Twiddling Hacks - By Sean Eron Anderson
Paj's Home
XySSL
高度な JavaScript 技集
0. ASP
aspfaq.com
codeproject.com
motobit.com
0. ASP.NET(C#)
ASP .NET FAQ
C# Frequently Asked Questions
C# General FAQ
C# MVP Bloggers
0. CSS
Comparison of layout engines (CSS)
0. Javascript
Comparison of layout engines (DOM)
Comparison of layout engines (ECMAScript)
crockford.com
faqts.com/javascript
Pat's Place: A technology demonstrator project.
0. SQL
Comparison of different SQL implementations
Comparison of SQL syntax
What are reserved Access, ODBC and SQL Server keywords?
What are the main differences between Access and SQL Server?
0. Tool Kits
ECMA Standards
faqts.com
Mozilla docs
RFC's
W3C TR
1. Search Engines
Alexa Web Search
All the web
AltaVista Search
AOL Web Search
Baidu
CrazySearch!
CSDN Blog Search
Excite
FeedsS's Blog
Google
Kingsoft
Lycos Search
Lyric Search
Mpeg Search
MSN Search
Search.com
SoGua
Soudu
xx-hacker
Yahoo [cn]
Yahoo [en]
Yisou
2. English Forum
#旺旺英语论坛
#英语写作论坛
Learners english club
3. Linux Forum
#三峡大学 LINUX联盟(RSS)
#中国 Linux 公社(RSS)
#黄嘴企鹅论坛(RSS)
Fedora 1.0 问题(RSS)
LINUX 1000 Q(RSS)
Linux 伊甸园(RSS)
4. PHP Forum
#中文PHP俱乐部(RSS)
#超越 PHP(RSS)
5. Other Site
#中国网络研究与搜索论坛
#在线翻译(RSS)
#常用书籍打包
#电子图书下载(RSS)
#科迈网(RSS)
#蓝色理想(RSS)
#西安信息资源网
CSDN.NET(RSS)
Google Hacker Database
Web Design Group
Webmaster world
6. Enjoy Site
#新华网论坛(RSS)
#极点视觉绘画站(RSS)
#涂鸦王国(RSS)
#牧文财经(RSS)
#猫扑大杂烩(RSS)
7. Resource
Active Perl
Apache
j2sdk-1_4_2-windows-i586
mm.mysql-2.0.4-bin.jar
mod_jk_1.2.5_2.0.47.dll
mod_rewrite
MySql
PHP
phpMailer
Source Forge Xoops
Tomcat
Web Server Resource
Win2k3
Zend
8. My Blog
#搜索引擎优化 Seo-GI
#绿色学院 - Green Institute
Blogcn(RSS)
GI Technology
GI-BB Developer Team
Green Institute
MSN Blog
Wallop Flash
Wallop HTML (RSS)
卐-_卍 信仰,理想,追求,博爱,自强,厚德.(RSS)
9. Music & Album
GaeAhit
USTC
VeryCD-MTV
A. Manual
Apache Manual
CSS Level 2 Manual
HTML 4.01 Manual
Javascript Manual
MySql Manual (cn) 2
MySql Manual (en) 1
PEAR Manual
PHP Manual
PHP-GTK Manual
Regular Expression Library
Smarty Manual
W3C Technical Reports and Publications
XHTML 1.0 Manual
XML 1.0 Manual
B. Google Cheat
Blog.com
ChinaUnix
cnblogs
donews
Google Groups
Teeta
Tom blog
Yahoo Groups
Yculblog
C. Friend's Blog
#我爱生命中存在的那一切(RSS)
#老贼在干嘛?(RSS)
#鸣乐谷
Color_Se SeSe 颜色(RSS)
Drink Drank Drunk
PLANTUNT的珍贵资源
D. SEO
Keywords 1 (Google)
Keywords 2 (Baidu)
Keywords 3 (Yisou)
Marketleap.com
Pagerank 1
Pagerank 2
Pagerank 3
Trafficzap.com
Uptimebot.com
Webconfs
E. Technology
http://bt.it.to/
http://bt.qq.to/
http://bt.zz.to/
http://du.u.to/
http://gi.dd.to/
http://gi.if.to/
http://gi.kk.to/
http://gi.pc.to
http://gi.xx.to/
http://mail.it.to/
http://nba.it.to
http://se.u.to/
F. Literature
#逐浪文学
KK 书库
G. Math/Geometry
台湾一个不错的数学站
H. Works
宝莱迪
I. SEO Link
paolid
shawl.qiu CSharp DotNet 个人资料管理系统
shawl.qiu CSharp DotNet 个人资料管理系统
shawl.qiu CSharp DotNet 个人资料管理系统
依梦卫浴-依梦洁具(北京)厂家直销店
卫浴生活坊
满意洁具馆
热弯玻璃
热熔玻璃
热熔玻璃
玻璃
玻璃制品
艺术玻璃
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 使用 javascript 函数 完美控制页面图片显示大小 By shawl.qiu 收藏

新一篇: Javascript 生成指定范围数值随机数 By shawl.qiu | 旧一篇: 玩转 Javascript 弹出窗口, 居中与居角扩大窗口至屏幕最大值 By shawl.qiu

使用 javascript 函数 完美控制页面图片显示大小 By shawl.qiu 


函数 fResizeImg(w, h, id) 功能说明:
1. 本函数实现了指定高宽度显示图片大小
2. 本函数实现了按比例显示指定的高宽度
3. 本函数实现了是否指定 id 进行操作, 若不指定 id, 默认为页面全部图片.
4. 本函数实现了自动添加单击事件
4.1 单击图片后弹出一个窗口显示图片
4.2 再单击弹出的窗口则关闭本窗口
5. 弹出窗口按图片大小居中显示
6. 完美支持 IE, Opera 浏览器, 但对 Firefox 支持不够完善(由于个人习惯, 鄙人不打算费精力去完善对 Firefox 的支持)

目录:
1. fResizeImg(w, h, id) 函数源码及调用演示

shawl.qiu 
2006-10-27
http://blog.csdn.net/btbtd

    linenum
  1. <script type="text/javascript">
  2. //<![CDATA[
  3. window.onload=function(){
  4.     fResizeImg(500, 500, 'img');
  5.     //fResizeImg(500, 500);
  6. }
  7.     /*------------------------------------------------------*\
  8.      * Subject: 使用 javascript 函数 完美控制页面图片显示大小 By shawl.qiu  
  9.      * 使用:
  10.      * --------------------------------------
  11.      * 1. Javascript 脚本块
  12.      *    window.onload=function(){
  13.      *        fResizeImg(500, 500, 'img');
  14.      *        //fResizeImg(500, 500);
  15.      *    }
  16.      *
  17.      * 2. html body 标签
  18.      * <body onload="fResizeImg(500, 500, 'textMain');" >
  19.      * --------------------------------------
  20.      * 注: 必须在页面加载完毕后使用本函数(这是基本的客户端应用概念)
  21.     \*-------------------------------------------------------*/
  22.     //---------------------------------begin function fResizeImg();
  23.     function fResizeImg(w, h, id){
  24.         var img='';
  25.         var obj;
  26.         if(id==undefined)obj=document.images;
  27.         else obj=document.getElementById(id).getElementsByTagName('img');
  28.         
  29.         for(var i=0; i<obj.length; i++){
  30.             img=obj[i];
  31.             if(img.width>w&&(img.height<img.width)){
  32.                 img.height=img.height-(img.height/(img.width/(img.width-w)))
  33.                 img.width=w;
  34.             }else if(img.height>h&&(img.height>img.width)){
  35.                 img.width=img.width-(img.width/(img.height/(img.height-h)))
  36.                 img.height=h;
  37.             }
  38.             
  39.             img.onclick=function(){
  40.                 try{ imgPopup.close();} catch(e){}
  41.                 imgPopup=open('#', 'imgurl', 'width=500, height=500, left='+(screen.availWidth-500)/2+
  42.                 ', top='+(screen.availHeight-500)/2)
  43.                 imgPopup.document.write('<script>document.onclick=function(){ close();} /* 单击关闭窗口 */ <\/script>');
  44.                 
  45.                 imgPopup.document.write('<img src="'+this.src+'"/>'+
  46.                     '<script>'+
  47.                         'var w, h;'+
  48.                         'var img=document.images[0];'+
  49.                         'if(navigator.appName=="Opera"){w=img.width+10; h=img.height+40} else {w=img.width+10; h=img.height+25};'+
  50.                         'self.resizeTo(w, h);'+
  51.                         'self.moveTo((screen.availWidth-img.width)/2,(screen.availHeight-img.height)/2)'+
  52.                     '<\/script>'+
  53.                     '<style>body{margin:0; padding:0;} .hd{visibility:hidden;}<\/style>');
  54.                 imgPopup.document.write('<p class="hd">ok</p>');
  55.                 imgPopup.document.close();
  56.                 imgPopup.focus();
  57.             }
  58.         } // shawl.qiu script
  59.     }
  60.     //---------------------------------end function fResizeImg();
  61. //]]>
  62. </script>


发表于 @ 2006年10月27日 16:42:00|评论(loading...)|编辑

新一篇: Javascript 生成指定范围数值随机数 By shawl.qiu | 旧一篇: 玩转 Javascript 弹出窗口, 居中与居角扩大窗口至屏幕最大值 By shawl.qiu

评论

#大名 发表于2008-04-01 16:30:45  IP: 58.247.112.*
dsdfsd
#大名 发表于2008-04-01 16:32:53  IP: 58.247.112.*
sadasdasdasdasdsad
#大名 发表于2008-04-01 16:35:13  IP: 58.247.112.*
dfgdf
发表评论  


登录
Csdn Blog version 3.1a
Copyright © shawl.qiu