From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/captiveportal/onstatechanged/index.html | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html (limited to 'files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged') diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html new file mode 100644 index 0000000000..3211026253 --- /dev/null +++ b/files/zh-cn/mozilla/add-ons/webextensions/api/captiveportal/onstatechanged/index.html @@ -0,0 +1,94 @@ +--- +title: onStateChanged +slug: Mozilla/Add-ons/WebExtensions/API/captivePortal/onStateChanged +translation_of: Mozilla/Add-ons/WebExtensions/API/captivePortal/onStateChanged +--- +
{{AddonSidebar()}}
+ +

Fires when the captive portal state changes.

+ +

Syntax

+ +
browser.captivePortal.onStateChanged.addListener(callback)
+browser.captivePortal.onStateChanged.removeListener(listener)
+browser.captivePortal.onStateChanged.hasListener(listener)
+
+ +

Events have three functions:

+ +
+
addListener(callback)
+
Adds a listener to this event.
+
removeListener(listener)
+
Stop listening to this event. The listener argument is the listener to remove.
+
hasListener(listener)
+
Check whether listener is registered for this event. Returns true if it is listening, false otherwise.
+
+ +

addListener syntax

+ +

Parameters

+ +
+
callback
+
+

Function that is called when this event occurs. The function is passed the following arguments:

+ +
+
details
+
+

string The captive portal state, being one of unknown, not_captive, unlocked_portal, or locked_portal.

+
+
+
+
+ +

Examples

+ +

Handle a change in captive portal status:

+ +
function handlePortalStatus(portalstatusInfo) {
+  console.log("The portal status is now: " + portalstatusInfo.details);
+}
+
+browser.captivePortal.onStateChanged.addListener(handlePortalStatus)
+
+ +

{{WebExtExamples}}

+ +

Browser compatibility

+ + + +

{{Compat("webextensions.api.captivePortal.onStateChanged")}}

+ + -- cgit v1.2.3-54-g00ecf