历史管理 onhashchange
2024-08-29 10:06:42
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script> //onhashchange : 事件:当hash值有变化的时候,就会触发 window.onload = function(){
var oInput = document.getElementById('input1');
var oDiv = document.getElementById('div1'); var obj = {}; oInput.onclick = function(){ var number = randomNum(35,7); oDiv.innerHTML = number; var oRD = Math.random(); obj[oRD] = number; window.location.hash = oRD; }; window.onhashchange = function(){
var number = obj[window.location.hash.substring(1)] || ''; oDiv.innerHTML = number;
}; function randomNum(alls,now){ var arr = [];
var newArr = []; for(var i=1;i<=alls;i++){
arr.push(i);
} for(var i=0;i<now;i++){
newArr.push( arr.splice(Math.floor(Math.random()*arr.length),1) );
} return newArr; } }; </script>
</head> <body>
<input type="button" value="35选7" id="input1" />
<div id="div1"></div>
</body>
</html>
最新文章
- javascript变量的作用域
- asp值mysql驱动
- MAC解决端口占用
- EF 自定义校验设置和捕获异常
- NodeJs 中的Crypto 加密模块
- CentOS下MySQL忘记root密码解决方法【转载】
- Linux下安装FTP
- Linux下OpenCV的环境搭建(转)
- javascript算法(一)
- dummy_backend_queue.go
- 带着萌新看springboot源码8(spring ioc源码 完)
- DCM、PLL、PMCD、MMCM相关
- 3.3.1 MyBatis框架介绍
- dynamo与cassandra区别
- 国内常用NTP服务器地址及
- Dictionary在多线程情况下
- echarta3 北京,上海地图
- Import SQL into MySQL with a progress meter
- ZOJ 1913 J-Eucild&#39;s Game
- 【Ubuntu】编写一个c语言代码