<!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>