Iframes and Cross-Document Communication

In this section of the Iframes Tutorial, we show how to use JavaScript to communicate between documents when using iframes. We demonstrate and describe how to obtain references across document boundaries to access iframe elements, window and document objects, page elements, properties, variables, and functions.

Pages listed below demonstrate and describe how to:

Access an Iframe and its Document and Content
How a document can interact with an iframe contained within it.
Access the Parent Document from an Iframed Document
How a document in an iframe can interact with its containing document.
Communicate from Iframe to Iframe
How multiple iframes within a document can interact with each other.
Use Frames Array for Referencing
How to use the frames array to access an iframed document.

Access Denied?

If documents are from different domains, attempting to communicate between them will trigger access denied errors due to JavaScript's Same Origin Policy. The postMessage method can be used to overcome this limitation.