Change the HTML content that is shown in an iframe:
The srcdoc property sets or returns the value of the srcdoc attribute in an iframe element.
The srcdoc attribute specifies the HTML content of the page to shown in the inline frame.
Tip: This attribute is expected to be used together with the sandbox and seamless attributes.
If a browser supports the srcdoc attribute, it will override the content specified in the src attribute (if present).
If a browser does NOT support the srcdoc attribute, it will show the file specified in the src attribute instead (if present).
The srcdoc property is supported in all major browsers, except Internet Explorer.
Note: The srcdoc propery is not supported in Opera 12 and earlier versions, or in Safari 5 and earlier versions.
Return the srcdoc property:
Set the srcdoc property:
Value | Description |
---|---|
HTML_code | Specifies the HTML content to show in the iframe. Must be valid HTML syntax |
Return Value: | A String, representing the HTML content that is shown in the iframe (if any) |
---|
Return the HTML content that is shown in an iframe:
The result of x will be:
HTML reference: HTML <iframe> srcdoc attribute