getElementById.contentDocument error in IE

The cross-browser equivalent to contentDocument (including Firefox itself, where contentDocument does work) is contentWindow.document.

So try:

alert(document.getElementById('iView').contentWindow.document);

contentWindow gets you a reference to the iframe’s window object, and of course .document is just the DOM Document object for the iframe.

Here’s an article that summarizes better.

Leave a Comment