我們的志工尚未將本文翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!
您也可以閱讀本文的 English (US) 版本。

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

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes Yes49 ? ? ?
Considers window.opener No No49 ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes49 ? ? ?
Considers window.opener Yes No No49 ? ? ?

See also

文件標籤與貢獻者

最近更新: connorshea,