Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/captiveportal/index.md
6581 views
---
title: captivePortal slug: Mozilla/Add-ons/WebExtensions/API/captivePortal page-type: webextension-api tags: - API - Add-ons - Extensions - Non-standard - Reference - WebExtensions - captivePortal browser-compat: webextensions.api.captivePortal
---

{{AddonSidebar}}

Determine the captive portal state of the user's connection. A captive portal is a web page displayed when a user first connects to a Wi-Fi network. The user provides information or acts on the captive portal web page to gain broader access to network resources, such as accepting terms and conditions or making a payment.

To use this API you need to have the "captivePortal" permission.

Properties

  • {{WebExtAPIRef("captivePortal.canonicalURL")}}

    • : Return the canonical URL of the captive-portal detection page. Read-only.

Functions

  • {{WebExtAPIRef("captivePortal.getLastChecked()")}}

    • : Returns the time, in milliseconds, since the last request was completed.

  • {{WebExtAPIRef("captivePortal.getState()")}}

    • : Returns the portal state as one of unknown, not_captive, unlocked_portal, or locked_portal.

Events

  • {{WebExtAPIRef("captivePortal.onConnectivityAvailable")}}

    • : Fires when the captive portal service determines that the user can connect to the internet.

  • {{WebExtAPIRef("captivePortal.onStateChanged")}}

    • : Fires when the captive portal state changes.

Browser compatibility

{{Compat}}

{{WebExtExamples("h2")}}