Click to See Complete Forum and Search --> : sWidth error in IE


MattS156
02-10-2003, 02:15 PM
I'm getting a javascript error in IE6 that I never got with earlier versions. It's a simple thumbnail script that pops up a window with a picture. The error is an Object Required error on line 27 of my script. When I looked at line 27, it read sWidth = win.document.body.clientWidth;. Here's the whole script, it's very simple. I'll isolate the line that shows the error. What's wrong with this line? I don't see anything that would indicate an error! Did this object change with IE6? Thanks in advance for your help.

function ViewImage(ifile,ix,iy,ititle) {
var win;
var sWidth;
var sHeight;
var NS = (document.layers) ? 1 : 0;
win = window.open("","imageviewer","width="+ix+",height="+iy+",menubar=no,toolbar=no");
if (NS) {
sWidth = win.innerWidth;
sHeight = win.innerHeight;
} else {

sWidth = win.document.body.clientWidth; <--- LINE WITH ERROR

sHeight = win.document.body.clientHeight;
}
if(sWidth!=ix || sHeight!=iy) {
win.close();
setTimeout("ViewImage('"+ifile+"',"+ix+","+iy+",'"+ititle+"')", 250);
return;
}
win.document.open();
win.document.write("<html><head><title>"+ititle+"</title>");
win.document.write("</head><body>");
win.document.write('<div style="position:absolute;width:'+ix+'px;height:'+iy+'px;left:0px;top:0px">');
win.document.write("<img src="+ifile+"></div>");
win.document.close();
}

MattS156
02-10-2003, 02:44 PM
I should add that the symptoms are as follows; When I click on a thumbnail, the window pops up and is the size specified in the link, but the title says "about:blank" and no picture loads. However, if I close the window and do it again, the picture loads and the correct window title appears. There's no pattern to it and it's not consistent.