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

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
srcdoc