TIL: Iframe tag has srcdoc attribute

Posted on Tags , ,

This attribute provides a way to pass HTML that will override the response from the src attribute.

One more thing, the Iframe with src attribute injected with innerHTML won’t execute the JavaScript returned from the src response.
But if we inject an Iframe with srcdoc that contains JavaScript, it will be executed.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.