DOM

Window.isSecureContext プロパティ

 編集:2022.09.11 by T.A.

[Edge]?。読取専用。→

実験的: これは実験的な機能です。本番で使用する前にブラウザー互換性一覧表をチェックしてください。

コンテキストが を必要とする機能を使用できるかどうかを示します。

構文
Window.isSecureContext
Window Window

¶真偽値。

機能検出

グローバル スコープの isSecureContext の真偽値を用いることで、安全なコンテクストかどうかをチェックすることで機能検出できます。

if (window.isSecureContext) {
  // Page is a secure context so service workers are now available
  navigator.serviceWorker.register("/offline-worker.js").then(function () {
    
  });
}
W=window.open("../Com/Test.htm"); //新しいウインドウを開き、Test.htm を読み込む。
D=W.isSecureContext;              //安全なコンテキストを必要とする機能を使用できるかを得る。
	//=true
W=window.open("../Com/Tes.htm"); //新しいウインドウを開き、Tes.htm(存在しない文書)を読み込む。
D=W.isSecureContext;             //=true。どういうことだろうか?。

テスト