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