阅读背景:

H5移动端返回刷新

来源:互联网 

废话不多说直接上代码。

a.html

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
		localStorage.pagecount = '0';
		$(function(){
			$("#a").click(function() {
				window.location.href = "b.html";
				var interval = setInterval(function() {
					if(localStorage.pagecount != '0') {
						query();
						clearInterval(interval); //关闭定时任务。
					}
				}, 100);
			});
		})
		function query(){
			alert("我刷新了。");
			window.location.reload();
		}
	</script>

	<body>
		<h1>欢迎进入A页面</h1>
		<button id="a">进入b页面</button>
	</body>

</html><!DOCTYPE html>
<html>




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: