在 Chrome 50 中,您可以查看某些 HTML 屬性是否支援由 JavaScript 中的 DOMTokenList 例項支援的選項。目前支援的國家/地區如下:
- iframe 沙箱選項
- 連結關係 (rel 屬性,或 JavaScript 中的 relLink)
以下提供簡短範例:
var iframe = document.getElementById(...);
if (iframe.sandbox.supports('an-upcoming-feature')) {
// support code for mystery future feature
} else {
// fallback code
}
if (iframe.sandbox.supports('allow-scripts')) {
// instruct frame to run JavaScript
// NOTE: this is well-supported, and just an example!
}
隨著支援的選項清單不斷增加及變更,您可以使用功能偵測功能,為網頁應用程式執行正確的動作。