Get IFrame’s document, from JavaScript in main document

You should be able to access the document in the IFRAME using the following code:

    document.getElementById('myframe').contentWindow.document

However, you will not be able to do this if the page in the frame is loaded from a different domain (such as google.com). This is because of the browser’s Same Origin Policy.

Leave a Comment