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

浏览器兼容性

另见