利用鼠标滚轮控制图片自动缩放的子程序

2006-01-07 11:20:00

<SCRIPT language=JavaScript type=text/JavaScript> function img_zoom(e, o) //图片鼠标滚轮缩放 { var zoom = parseInt(o.style.zoom, 10) || 100; zoom += event.wheelDelta / 12; if (zoom > 0) o.style.zoom = zoom + '%'; return false; } </SCRIPT> <IMG onmousewheel="return img_zoom(event,this)" alt="鼠标的滚轮控制图片自动缩放" src="" onload="javascript:if(this.width>screen.width-500)this.width=screen.width-500"> 作者:Liubao 网址:http://liubao.com 邮件:zhouliubao_at_126.com 日期:2005-08-21 功能:鼠标滚轮实时缩放图片功能 实现平台:LBS Ver. 2.0.304 演示地点:http://liubao.com/bokee/ ///////////////////// 转载自 Loveyuki 's BLOG <script language="javascript"> <!-- var flag=false; function resizeImg(obj){ var image=new Image(); image.src=obj.src; if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= 200/160){ if(image.width>200){ obj.width=200; obj.height=(image.height*200)/image.width; }else{ obj.width=image.width; obj.height=image.height; } }else{ if(image.height>160){ obj.height=160; obj.width=(image.width*160)/image.height; }else{ obj.width=image.width; obj.height=image.height; } } } } //--> </script>