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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
isSecureContext | Chrome Full support Yes | Edge Full support 15 | Firefox Full support 49 | IE ? | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 49 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Considers window.opener | Chrome No support No | Edge No support No | Firefox Full support 49 | IE ? | Opera ? | Safari ? | WebView Android Full support Yes | Chrome Android No support No | Firefox Android Full support 49 | Opera 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.