Forum Moderators: open

Message Too Old, No Replies

IE5 error

         

jackvull

9:51 am on Jan 12, 2006 (gmt 0)

10+ Year Member



Hi
I have a function that loads a jpg into an iframe when users click on a link. This works fine in IE6 but in IE 5, it turns out that I get the following error:
'document.getElementById(...).contentWindow.document\' is not an object

What should I use instead to support IE5?

ajkimoto

7:24 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



jackvull,

I have used this in the past, where iFrameObj is a reference to the iframe object:

if (IFrameObj.contentDocument) {
// For Gecko
IFrameDoc = IFrameObj.contentDocument;
} else if (IFrameObj.contentWindow) {
// For IE5.5 and IE6
IFrameDoc = IFrameObj.contentWindow.document;
} else if (IFrameObj.document) {
// For IE5
IFrameDoc = IFrameObj.document;
} else {
return true;
}

This gives you a unified reference IFrameDoc to the document contained in the iframe. You could then manipulate it like this:

IFrameDoc.location.replace(URL)

Hope this helps,

ajkimoto

DrDoc

8:29 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You also need something like:

IFrameObj = (document.getElementById?document.getElementById('...'):document.all['...']);