Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

JS监听Chrome回退按钮失败?

image.png
这段代码在进入页面的时候不做任何操作直接点击chrome回退按钮则没效果,如果进入页面点击下其他地方则可以监听到,有大佬知道什么原因嘛,我需要实现两种情况都能监听到


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

放弃吧。浏览器故意这样做的,防止恶意网站劫持用户返回。
用户在你的网站啥都没操作就离开,说明用户对你的网站内容不感兴趣,这个时候如果用户要点击返回按钮离开,浏览器就直接放行,网站无法劫持。Chrome plans to save you from sites that mess with your back button


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...