HTMLIFrameElement:src 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLIFrameElement.src
是一个反映包含要嵌入内容地址的 src
HTML 属性的字符串。
请注意,以编程的方式,通过 Element.removeAttribute()
等方法从 <iframe>
中移除 src
属性会导致 iframe 加载 about:blank
。
语法
js
src = iframeElt.src
iframeElt.src = src
示例
js
const iframe = document.createElement("iframe");
iframe.src = "/";
const body = document.querySelector("body");
body.appendChild(iframe); // 使用完整的 URL 作为引用源来获取图像
规范
Specification |
---|
HTML # dom-iframe-src |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
src |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.