用鼠标滑轮控制图片大小的显示

脚本代码如下:
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;
}


例子:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BillDetail.aspx.cs" Inherits="WebTest_BillDetail" %>
   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用鼠标滑轮控制图片大小的显示</title>
<script type="text/javascript" language="javascript">
    // <![CDATA[
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="http://images.cnblogs.com/help/hj_arrow.gif"
onmousewheel = "javascript:return big(this)" height="219" alt=""/>

    </form>
</body>
</html>

 

posted @ 2008-07-15 18:30 liyundong 阅读(235) 评论(0) 编辑 收藏