Window.isSecureContext

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The window.isSecureContext read-only property indicates whether a context is capable of using features that require secure contexts.

Syntax

var isSecure = window.isSecureContext

Examples

Feature detection

You can use feature detection to check whether they are in a secure context or not by using the isSecureContext boolean which is exposed on the global scope.

if (window.isSecureContext) {
  // Page is a secure context so service workers are now available
  navigator.serviceWorker.register("/offline-worker.js").then(function () {
    ...
  });
}

Specifications

Specification Status Comment
Secure Contexts Candidate Recommendation Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
isSecureContextChrome Full support YesEdge Full support 15Firefox Full support 49IE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 49Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
Considers window.opener
Experimental
Chrome No support NoEdge No support NoFirefox Full support 49IE ? Opera ? Safari ? WebView Android Full support YesChrome Android No support NoFirefox Android Full support 49Opera Android ? Safari iOS ? Samsung Internet Android No support No

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See also