
| ´úÂëÈçÏ | |
<script language="JavaScript"> ImgD.alt=image.width+"×"+image.height; |
|
ʵÀý¶þ
| ´úÂëÈçÏ | |
| function resizeimg(ImgD,iwidth,iheight) { var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ if(image.width/image.height>= iwidth/iheight){ if(image.width>iwidth){ ImgD.width=iwidth; ImgD.height=(image.height*iwidth)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"×"+image.height; } else{ if(image.height>iheight){ ImgD.height=iheight; ImgD.width=(image.width*iheight)/image.height; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"×"+image.height; } ImgD.style.cursor= "pointer"; //¸Ä±äÊó±êÖ¸Õë ImgD.onclick = function() { window.open(this.src);} //µã»÷´ò¿ª´óͼƬ if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //ÅжÏä¯ÀÀÆ÷£¬Èç¹ûÊÇIE ImgD.title = "ÇëʹÓÃÊó±ê¹öÂÖËõ·ÅͼƬ£¬µã»÷ͼƬ¿ÉÔÚд°¿Ú´ò¿ª"; ImgD.onmousewheel = function img_zoom() //¹öÂÖËõ·Å { var zoom = parseInt(this.style.zoom, 10) || 100; zoom += event.wheelDelta / 12; if (zoom> 0)¡¡this.style.zoom = zoom + "%"; return false; } } else { //Èç¹û²»ÊÇIE ImgD.title = "µã»÷ͼƬ¿ÉÔÚд°¿Ú´ò¿ª"; } } } |
|
ÔÚÐèҪʵÏֵȱÈËõ·ÅµÄͼƬÉϼÓÉÏonloadÓï¾ä£¬Í¼Æ¬×°ÔØÊ±³õʼ»¯´óС¡£
¾ßÌåʵÏÖ´úÂëÈçÏÂ:
| ´úÂëÈçÏ | |
<img name="" src="" onload="javascript:resizeimg(this,100,200)"> |
|