1. 面向开发者的 Web 技术
  2. Web API
  3. PageTransitionEvent

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

PageTransitionEvent

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

Page transition events fire when a webpage is being loaded or unloaded.

当网页在加载完成或卸载后会触发页面传输事件(Page transition events)。

DOM Information

Inheritance Hierarchy

EventPageTransitionEvent

Example

HTML

html
<!doctype html>
<html>
 <body onpageshow="myFunction(event)"></body>
</html>

JavaScript

js
function myFunction(event) {
 if (event.persisted) {
 alert("The page was cached by the browser");
 } else {
 alert("The page was NOT cached by the browser");
 }
}

Members

The PageTransitionEvent object has these types of members:

  • Properties

Properties

The PageTransitionEvent object has these properties.

Property Access type Description
persisted 只读 标记页面是否从缓存(Backforward Cache)中加载

帮助改进 MDN

了解如何参与贡献

此页面最后更新于 ,由 MDN 贡献者更新。

AltStyle によって変換されたページ (->オリジナル) /