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.
var isSecure = window.isSecureContext
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 () {
...
});
} | Specification | Status | Comment |
|---|---|---|
| Secure Contexts | Candidate Recommendation | Initial definition. |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes | Yes | 49 | ? | ? | ? |
Considers window.opener
|
No | No | 49 | ? | ? | ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | Yes | Yes | 49 | ? | ? | ? |
Considers window.opener
|
Yes | No | No | 49 | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/window/isSecureContext