• Skip to main content
  • Skip to search
  • Skip to select language
MDN Web Docs
  • 参考手册
    • 概述 / Web 技术

      适用于开发者的 Web 技术参考手册

    • HTML

      Web 内容的结构

    • CSS

      用于描述文档样式的代码

    • JavaScript

      通用脚本语言

  • 开发指南
    • 概述 / MDN 学习区

      学习 Web 开发

    • MDN 学习区

      学习 Web 开发

    • HTML

      学习使用 HTML 构建 Web 内容

    • CSS

      学习使用 CSS 设置内容样式

    • JavaScript

      学习在浏览器中运行脚本

  • 更多中文网
  1. 面向开发者的 Web 技术
  2. 网络 API
  3. HTMLIFrameElement
  4. srcdoc

目录

  • Examples
  • Specifications
  • Browser compatibility
  1. HTMLIFrameElement
  2. Instance properties
    1. allow
    2. allowFullscreen
    3. allowPaymentRequest Non-standard Deprecated
    4. browsingTopics Experimental Non-standard
    5. contentDocument
    6. contentWindow
    7. credentialless Experimental
    8. csp Experimental
    9. featurePolicy Experimental
    10. height
    11. loading
    12. name
    13. referrerPolicy
    14. sandbox
    15. src
    16. srcdoc
    17. width
  3. Inheritance
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget

目录

  • Examples
  • Specifications
  • Browser compatibility

HTMLIFrameElement: srcdoc property

The srcdoc property of the HTMLIFrameElement specifies the content of the page.

Examples

js
const iframe = document.createElement("iframe");
iframe.srcdoc = `<!DOCTYPE html><p>Hello World!</p>`;
document.body.appendChild(iframe);

Specifications

Specification
HTML Standard
# dom-iframe-srcdoc

Browser compatibility

BCD tables only load in the browser

MDN Web 中文网 - 粤ICP备13048890号