• JavaScript实现的抽奖效果【数字跳动版】


    直接上代码吧,效果可以复制了去看 

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
        
    <title></title>
        
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
        
    <style type="text/css">
            .a1
            
    {
                position
    : relative;
                font-family
    : Verdana;
                font-size
    : 200px;
                color
    : #888888;
            
    }

        
    </style>

        
    <script language="JavaScript">
            
    function Lottery() {
                
    var Nos = Math.round(Math.random() * (4999 - 1+ 1);

                
    var result = document.getElementById("layer1");
                
    if (result != null{
                    result.innerHTML 
    = Nos;
                }


                T 
    = setTimeout('Lottery()', 30);
            }

            
    //-->
        
    </script>

    </head>
    <body>
        
    <div>
            
    <input type="button" value='Lottery Number Picker' onclick="Lottery();setTimeout('clearTimeout(T)',2000);" />
        
    </div>
        
    <div>
            
    <span id="layer1" class="a1">Result</span>
        
    </div>
    </body>
    </html>

    补充:

    后来我在调试程序的过程中发现,以上程序在Firefox中运行良好,但是在IE7经常会出现数字停不下来的情况,把Lottery()的递归时间从10毫秒改到30毫秒以后问题解决。

  • 相关阅读:
    PHP线程安全
    Oracle中MD5+Base64加密实现
    1002. A+B for Polynomials (25)
    1001. A+B Format (20)
    Rails,uva 514
    Database,Uva1592
    Hello World for U
    D3.js 力导向图
    从零开始CSS(一 2016/9/21)
    从零开始HTML(三 2016/9/20)
  • 原文地址:https://www.cnblogs.com/MikeYao/p/1596128.html
Copyright © 2020-2023  润新知