富贵资源网 Design By www.hznty.com

复制代码 代码如下:
<html>
<head>
<title></title>
<script type="text/javascript" language="javascript">

    /*根据获得焦点的时候给setVal给值*/
    var setVal;  
    var bool = false;    
    var scrollFunc=function(e){ 
        var direct=0; 
        e=e || window.event; 
        var ew = e.wheelDelta
        if(ew && bool){
            if(ew > 0){
                var num1 = setVal.value;
                if(num1 > 0){
                    num1 = eval(1+parseInt(num1));
                }else{
                    num1 = 1;
                }
            }else{
                var num1 = setVal.value;
                if(num1 > 0){
                    num1 = eval(parseInt(num1)-1);
                }else if(num1 == 0){
                    num1 = 0;
                }else{
                    num1 = 1;
                }   
            }

            setVal.value = num1;
        }

    } 
    window.onmousewheel=document.onmousewheel=scrollFunc;

    function ufocus(eve){
        bool = true;
        setVal = eve;
    }

    function ublur(){
        bool = false;
        setVal = null;
    }
</script>
</head>

<body>
<input type="text" onfocus="ufocus(this)" onblur="ublur(this)"/>
</body>

</html>

<html>

<head>

<title></title>
<script type="text/javascript" language="javascript">

    /*根据获得焦点的时候给setVal给值*/
    var setVal;
    var bool = false;  
    var scrollFunc=function(e){
        var direct=0;
        e=e || window.event;
        var ew = e.wheelDelta
        if(ew && bool){
            if(ew > 0){
                var num1 = setVal.value;
                if(num1 > 0){
                    num1 = eval(1+parseInt(num1));
                }else{
                    num1 = 1;
                }
            }else{
                var num1 = setVal.value;
                if(num1 > 0){
                    num1 = eval(parseInt(num1)-1);
                }else if(num1 == 0){
                    num1 = 0;
                }else{
                    num1 = 1;
                } 
            }

            setVal.value = num1;
        }

    }

    window.onmousewheel=document.onmousewheel=scrollFunc;

    function ufocus(eve){
        bool = true;
        setVal = eve;
    }

    function ublur(){
        bool = false;
        setVal = null;
    }
</script>
</head>

<body>
<input type="text" onfocus="ufocus(this)" onblur="ublur(this)"/>
</body>

</html>

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com