aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/issecurecontext
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/issecurecontext
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/issecurecontext')
-rw-r--r--files/zh-cn/web/api/window/issecurecontext/index.html120
1 files changed, 120 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/window/issecurecontext/index.html b/files/zh-cn/web/api/window/issecurecontext/index.html
new file mode 100644
index 0000000000..63f29098c9
--- /dev/null
+++ b/files/zh-cn/web/api/window/issecurecontext/index.html
@@ -0,0 +1,120 @@
+---
+title: Window.isSecureContext
+slug: Web/API/Window/isSecureContext
+translation_of: Web/API/Window/isSecureContext
+---
+<p>{{APIRef}}{{SeeCompatTable}}</p>
+
+<p><code><strong>window.isSecureContext</strong>是一个判断上下文是否能够使用<a href="https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts">安全上下文</a>的特征的只读属性<strong>。</strong></code></p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var <em>isSecure</em> = window.isSecureContext</pre>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="特征检测">特征检测</h3>
+
+<p>你可以使用特征检测来判断上下文是否处于安全的上下文之中通过使用在全局作用域下公共的<strong>isSecureContext</strong>返回的布尔值。</p>
+
+<pre class="brush: js">if (window.isSecureContext) {
+ // 页面是是个安全的上下文,服务可以正常使用。
+ navigator.serviceWorker.register("/offline-worker.js").then(function () {
+ ...
+ });
+}</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Specification</th>
+ <th>Status</th>
+ <th>Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Secure Contexts')}}</td>
+ <td>{{Spec2('Secure Contexts','#monkey-patching-global-object','isSecureContext')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Considers <a href="/en-US/docs/Web/API/Window/opener">window.opener</a></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoDesktop(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Considers <a href="/en-US/docs/Web/API/Window/opener">window.opener</a></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/Security/Secure_Contexts">Secure contexts</a></li>
+</ul>