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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。