简体   繁体   English

检测window.location的变化

[英]Detecting changes in window.location

I am trying to detect changes in window.location (for example to be notified if the user tries to reload the page) but I can't seem to find a way to do that. 我正在尝试检测window.location的变化(例如,如果用户尝试重新加载页面,则会收到通知),但是我似乎找不到解决方法。 Are there some events associated with it? 是否有与此相关的事件?

Thanks 谢谢

The unload event is fired when the user leaves the page. 当用户离开页面时,将触发unload事件。 There's also a beforeunload event in some browsers, but it's not supported in Opera . 在某些浏览器中,还有一个beforeunload事件,但Opera不支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM