Window: pagehide event - Web APIs 编辑
The pagehide
event is sent to a Window
when the browser hides the current page in the process of presenting a different page from the session's history. For example, when the user clicks the browser's Back button, the current page receives a pagehide
event before the previous page is shown.
Bubbles | No |
---|---|
Cancelable | No |
Interface | PageTransitionEvent |
Event handler property | onpagehide |
Examples
In this example, an event handler is established to watch for pagehide
events and to perform special handling if the page is being persisted for possible reuse.
window.addEventListener("pagehide", event => {
if (event.persisted) {
/* the page isn't being discarded, so it can be reused later */
}
}, false);
This can also be written using the onpagehide
event handler property on the Window
:
window.onpagehide = event => {
if (event.persisted) {
/* the page isn't being discarded, so it can be reused later */
}
}
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'pagehide' in that specification. | Living Standard | Initial specification. |
HTML5 The definition of 'pagehide' in that specification. | Recommendation |
Browser compatibility
BCD tables only load in the browser
See also
- The
pageshow
event
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论