检测window.location中的更改 [英] Detecting changes in window.location

查看:118
本文介绍了检测window.location中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检测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. Are there some events associated with it?

谢谢

推荐答案

当用户离开页面时会触发卸载事件。在某些浏览器中还有一个 beforeunload 事件,但它是 Opera不支持

The unload event is fired when the user leaves the page. There's also a beforeunload event in some browsers, but it's not supported in Opera.

这篇关于检测window.location中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆