javascript - 在用户导航到其他 URL 之前触发的浏览器事件

标签 javascript html

对于 HTML5 兼容的浏览器,我们是否在用户导航到其他 URL 之前触发了一个事件?

我的要求是,如果用户通过单击链接或更改 location.href 导航到其他页面,则弹出一个确认对话框。

最佳答案

我猜你正在寻找 onbeforeunload

关于javascript - 在用户导航到其他 URL 之前触发的浏览器事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11012723/

相关文章:

javascript - jQuery - 触发事件而不是设置它

javascript - 如何使用 jQuery 检测 URL 更改

html - 如果数字值中没有声明任何内容,则设置的度量单位是什么 [ CSS ]

javascript - 通过 Javascript 更改元素的显示?

javascript - 脚本中没有被编译

Javascript onbeforeunload - 在退出时显示图像

javascript - jQuery text() 和换行符

html - 防止使用 srcset 进行放大?

html - 如何使用 css 叠加图像(跨浏览器)

javascript - 正则表达式 : Allow only use of a few words and only once per word