Blogger Information
Blog 56
fans 7
comment 11
visits 222527
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js监听微信浏览器返回按钮事件
樂成的开发笔记
Original
1899 people have browsed it

js监听微信浏览器返回按钮事件,比较实用的一个功能,比如填写资料没有实时保存数据的话,避免返回误操作

<script>
	pushHistory();
		window.addEventListener("popstate", function(e) {
			//alert("我监听到了浏览器的返回按钮事件啦");//根据自己的需求实现自己的功能
			window.location.href="{:U('App/Shop/goodsList')}";
	}, false);  
	function pushHistory(){
		var state = {  
			title: "title",  
			url: "#"  
		};  
		window.history.pushState(state, "title", "#");  
	}
</script>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post