srcdoc

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

Examples

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

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'HTMLIFrameElement: srcdoc' in that specification.
Living Standard

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
srcdocChrome Full support 43Edge Full support 79Firefox Full support 25IE No support NoOpera Full support YesSafari Full support 6WebView Android Full support YesChrome Android Full support 18Firefox Android Full support 25Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0

Legend

Full support
Full support
No support
No support