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.