From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/pagetransitionevent/index.html | 73 ++++++++++++++++++++++ .../api/pagetransitionevent/persisted/index.html | 45 +++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 files/zh-cn/web/api/pagetransitionevent/index.html create mode 100644 files/zh-cn/web/api/pagetransitionevent/persisted/index.html (limited to 'files/zh-cn/web/api/pagetransitionevent') diff --git a/files/zh-cn/web/api/pagetransitionevent/index.html b/files/zh-cn/web/api/pagetransitionevent/index.html new file mode 100644 index 0000000000..756e0c81d0 --- /dev/null +++ b/files/zh-cn/web/api/pagetransitionevent/index.html @@ -0,0 +1,73 @@ +--- +title: PageTransitionEvent +slug: Web/API/PageTransitionEvent +translation_of: Web/API/PageTransitionEvent +--- +

{{APIRef("HTML DOM")}}

+ +

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

+ +

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

+ +

DOM Information

+ +

 

+ +

Inheritance Hierarchy

+ +
 Event +
   PageTransitionEvent
+
+ +

Example

+ +

HTML

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

JavaScript

+ +
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

+ +

The PageTransitionEvent object has these properties.

+ + + + + + + + + + + + + + +
PropertyAccess typeDescription
+

persisted

+
只读 +

标记页面是否从缓存(Backforward Cache)中加载

+
+ +

 

diff --git a/files/zh-cn/web/api/pagetransitionevent/persisted/index.html b/files/zh-cn/web/api/pagetransitionevent/persisted/index.html new file mode 100644 index 0000000000..831eb7bbf7 --- /dev/null +++ b/files/zh-cn/web/api/pagetransitionevent/persisted/index.html @@ -0,0 +1,45 @@ +--- +title: PageTransitionEvent.persisted +slug: Web/API/PageTransitionEvent/persisted +translation_of: Web/API/PageTransitionEvent/persisted +--- +
{{APIRef("HTML DOM")}}
+ +

只读属性persisted代表一个页面是否从缓存中加载的

+ +

Syntax

+ +
window.addEventListener('pageshow', function(event) {
+  if (event.persisted) {
+    console.log('Page was loaded from cache.');
+  }
+});
+ +

Value

+ +

A {{jsxref("Boolean")}}.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-pagetransitionevent-persisted', 'PageTransitionEvent: persisted')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.PageTransitionEvent.persisted")}}

-- cgit v1.2.3-54-g00ecf