HTMLIFrameElement: src 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

HTMLIFrameElement.src 屬性是一個字串,它反映了 src HTML 屬性,其中包含要嵌入的內容的地址。

請注意,透過程式設計方式移除 <iframe> 的 src 屬性(例如,透過 Element.removeAttribute())會導致在框架中載入 about:blank

示例

js
const iframe = document.createElement("iframe");
iframe.src = "/";
const body = document.querySelector("body");
body.appendChild(iframe); // Fetch the image using the complete URL as the referrer

規範

規範
HTML
# dom-iframe-src

瀏覽器相容性

另見