用鼠标滑轮控制图片大小js

遇到这样一个需求,从网上摘了段代码过来。。。

PS:

1.不要忘记,有的时候在页面上直接用js,jsp会出不来,要用引入的方法。

2.可以改变js起作用的区域。

<html>

  <head runat="server">
    <title>用鼠标滑轮控制图片大小的显示</title>
<script type="text/javascript" language="javascript">
function big(o)
    {
     var zoom=parseInt(o.style.zoom, 10)||100;
     zoom+=window.event.wheelDelta/12;


     if (zoom>0) o.style.zoom=zoom+'%';


     return false; 
    }
    </script>
</head>
<body>
    <form id="form1" runat="server" style="background-color:Gray;">
<img onload="javascript:if(this.width>498)this.style.width=498;" 
src="Images/1.JPG" 
onmousewheel = "javascript:return big(this)" height="219" alt=""/>
    </form>
</body>

</html>

我测试过了。好用,但代码是真心看不懂啊。请朋友们给我指点下迷津。

你可能感兴趣的:(用鼠标滑轮控制图片大小js)