Window: credentialless 屬性
window.credentialless 只讀屬性返回一個布林值,指示當前文件是否在無憑證 (credentialless) 的 <iframe> 中載入,這意味著它在一個新的、臨時的上下文中載入。
此上下文無法訪問與其源相關的網路、Cookie 和儲存資料。它使用一個獨立於頂級文件生命週期的新上下文。作為回報,Cross-Origin-Embedder-Policy (COEP) 嵌入規則可以被解除,因此設定了 COEP 的文件可以嵌入未設定 COEP 的第三方文件。
有關更深入的解釋,請參閱 IFrame credentialless。
值
一個布林值。值為 true 表示文件在無憑證 <iframe> 中載入;值為 false 表示未在此上下文中載入。
示例
您可以如下方式指定一個無憑證 <iframe>:
html
<iframe
src="https://en.wikipedia.org/wiki/Spectre_(security_vulnerability)"
title="Spectre vulnerability Wikipedia page"
width="960"
height="600"
credentialless></iframe>
在支援的瀏覽器中,如果載入到 <iframe> 中的文件執行以下行,它將返回 true:
js
console.log(window.credentialless);
規範
| 規範 |
|---|
| Iframe credentialless # dom-window-credentialless |
瀏覽器相容性
載入中…