浏览器后退按钮拦截js

原创 六月初 随笔 工作笔记 150阅读 2018-01-13 11:28:31 举报

<script language="javascript">
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/stealingyourhistory");
history.pushState(null, document.title, location.pathname);
window.addEventListener("popstate", function() {
if(location.hash === "#!/stealingyourhistory") {
history.replaceState(null, document.title, location.pathname);
setTimeout(function(){
location.replace("www.baidu.com");
},0); } }, false); }(window, location));
</script>

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复