javascriptiframesame-origin-policywindow-object

Exposing a window object's document


I have a iframe whose content will be exposed by iframeObject.contentWindow. This returns a window object, according to mozilla developer network

this window object to access the iframe's document and it's internal dom.

However, I cannot figure out how to expose the document from the window object.


Solution

  • You can access the contentDocument property

    HTMLIFrameElement.contentDocument

    Returns a Document, the active document in the inline frame's nested browsing context.