Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM IFrame contentDocument Property

Improve Article
Save Article
Like Article
  • Last Updated : 17 Jun, 2022
Improve Article
Save Article
Like Article

The IFrame contentDocument property in HTML DOM is used to return the document object generated by a frame or iframe element. It can be used in the host window to access the document object that belongs to a frame or iframe element. 



Return Value: It returns the reference of the document object. If there is no object available then it returns null. 



<!DOCTYPE html>
        HTML DOM iframe contentDocument Property
<body style="text-align:center;">
        HTML DOM iframe contentDocument Property
                id="GFG" height="200" width="400">
    <button onclick="Geeks()">
        function Geeks() {
            var iframeID = document.getElementById("GFG");
            var iframeCW = (iframeID.contentWindow
                    || iframeID.contentDocument);
            if (iframeCW.document)iframeCW = iframeCW.document;
       = "5px solid black";

  • Before Clicking on the Button:


  • After Clicking on the Button:


Supported Browsers: The browsers supported by HTML DOM IFrame contentDocument property are listed below:

  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Firefox 1.0 and above
  • Internet Explorer 8.0 and above
  • Opera 12.1 and above
  • Safari 3.0 and above

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!