Categories
JavaScript Answers

How to write elements into a child iframe using JavaScript?

Spread the love

Sometimes, we want to write elements into a child iframe using JavaScript.

In this article, we’ll look at how to write elements into a child iframe using JavaScript.

How to write elements into a child iframe using JavaScript?

To write elements into a child iframe using JavaScript, we use the contentDocument property.

For instance, we write

const iframeDocument = document.getElementById("iframeID").contentDocument;

to get the iframe with getElementById.

Then we get its document object with contentDocument.

Conclusion

To write elements into a child iframe using JavaScript, we use the contentDocument property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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