Forum Moderators: open

Message Too Old, No Replies

MSIE 5.0 error

         

jackvull

9:01 am on Oct 17, 2005 (gmt 0)

10+ Year Member



Hi I get this error when a user with MSIE 5.0 tries to do something on my site (loading a picture into an iframe):
\document.getElementById(...).contentWindow.document\ is not an object

Is there a known workaround for this?
Seems to work fine with MSIE 6.0 and other browsers...

iamlost

3:38 am on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Unfortunately they access an <iframe>'s document object differently:

IE5(Mac/Win) uses the document.frames array document property.

IE5.5/6.0 uses (as you scripted) document.getElementByID() and contentWindow.document.

Try something like (this is off the cuff, not trialed):


// For IE5.5 and IE6.0
if (IFrameObj.contentWindow) {
IFrameDoc = IFrameObj.contentWindow.document;
}
// For IE5.0
else if (IFrameObj.document) {
IFrameDoc = IFrameObj.document;
}
else ...

jackvull

9:15 am on Oct 18, 2005 (gmt 0)

10+ Year Member



Ok - I am trying to do this at the moment but have 2 questions:
function showimageinframe(imagelink,framename,width,height) {
if (contentWindow.document) {
var source = '<img width="'+width+'" height="'+height+'" src="'+imagelink+'" />';
var myframe = document.frames(framename);
myframe.open();
myframe.write(source);
myframe.close();

}

else if (document.getElementById) {
alert("HERE");
var source = '<img width="'+width+'" height="'+height+'" src="'+imagelink+'" />';
var myframe = document.getElementById(framename).contentWindow.document;
myframe.open();
myframe.write(source);
myframe.close();
}

}

1. It doesn't seem to like if (contentWindow.document) so I must be doing something wrong here; and
2. I wasn't sure about var myframe = document.frames(framename); will the brackets work in this case?

iamlost

4:22 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I just posted the "if" statements to show the "problem" as I did not know your code. Please post the original code that only broke in IE5.0.