Friday, June 1, 2012

Javascript Communicating Across IFrames

It is possible Javascript for scripts in one IFrame to call another.

First, get the element for the iframe:

var iframeElement = document.getElementById('frameX');

Then, obtain the document object (IE and other browsers use different methods, so we have to cover both):

var iframeDocument = (iframeElement.contentDocument || iframeElement.contentWindow.document);

You can then work on iframeDocument as you would the "document" object.

Refererences:

No comments:

Post a Comment