• jszs 历史管理


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload = function ()
    {
        var odiv = document.getElementById('div1');
        var obtn = document.getElementById('btn');
        
        
        
        obtn.onclick = function ()
        {
            var number = randnew(35,7);
            
            odiv.innerHTML = number;
            history.pushState(number,'');        
            
        }
        
        window.onpopstate = function (ev)
        {
            var number = ev.state||'';
            odiv.innerHTML = number;
        }
        
        
        
        function randnew(alls,news)
        {
            var arr = [];
            var newarr = [];
            for(var i = 1; i <= alls; i++)
            {
                arr.push(i);
            }
            
            for( var i = 0; i < news; i++)
            {
                newarr.push(arr.splice(Math.floor(Math.random()*arr.length),1));
            }
            
            return newarr;
        }
    };
    </script>
    </head>
    
    <body>
    <input id="btn" type="button" value="35选7">
    <div id="div1"></div>
    </body>
    </html>
  • 相关阅读:
    Java自学第十天
    Java自学第九天
    Java自学第八天
    Java自学第七天
    Java自学第六天
    Java自学第五天
    Java自学第四天
    Java自学第三天
    Oracle11g RAC单节点重启
    PostgreSQL 日志处理
  • 原文地址:https://www.cnblogs.com/mayufo/p/4260249.html
Copyright © 2020-2023  润新知