window属性:isSecureContext

2018-04-10 10:52 更新

isSecureContext属性

提示:在使用此功能之前,请仔细检查浏览器兼容性表。

该 window.isSecureContext 只读属性表示上下文是否能够使用需要功能的安全环境。

isSecureContext属性语法

var isSecure = window.isSecureContext

isSecureContext属性示例

特征检测

您可以使用特征检测来检查它们是否处于安全上下文中,或通过使用全局范围中公开的 isSecureContext 布尔值来检查它们是否处于安全上下文中。

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

规范

规范状态注释
安全的上下文Candidate Recommendation
初始定义

浏览器兼容性

我们正在将兼容性数据转换为机器可读的JSON格式。

  • 电脑端
特征Chrome
Edge
Firefox(Gecko)
Internet Explorer
Opera
Safari(WebKit)
基本支持支持支持支持:49
考虑window.opener不支持不支持支持:49
  • 移动端

特征AndroidAndroid WebviewEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
基本支持不支持支持支持支持:49.0???支持
考虑 window.opener不支持支持不支持支持:49.0????
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号