Forum Moderators: open

Message Too Old, No Replies

specific browser error?

         

jackvull

10:26 am on Oct 14, 2005 (gmt 0)

10+ Year Member



Hi
I received the following error through my JavaScript error tracking procedures on my webpage:
URI:
/javascriptError.php?msg=\'document.getElementById(...).contentWindow.document\'%20is%20not%20an%20object&url=http://www.wahalla.co.uk/gallery.php?PHPSESSID=b0b32b063f8b6e1c236727e251085dbd&ln=112
Agent: Mozilla/4.0 (compatible; MSIE 5.14; Mac_PowerPC) Message:
\document.getElementById(...).contentWindow.document\ is not an object
Line: 112

Basically, I have a page where users click on a link and a .jpeg is loaded into a small iframe and automatically resized. The Javascript that does this is:
function showimageinframe(imagelink,framename,width,height) {
/* function showimageinframe by Sathallrin */
var source = '<img width="'+width+'" height="'+height+'" src="'+imagelink+'" />';
var myframe = document.getElementById(framename).contentWindow.document;
myframe.open();
myframe.write(source);
myframe.close();
}

Is there something in IE 5.14 that would prevent this from working properly or could it be to do with the Mac?

Many thanks.

Bernard Marx

12:38 pm on Oct 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



(possibly) It might be easier to include a small function in the iframe itself, and let it handle it's own requests.

The iframe, in this case will bring in it's own document (no document.write), which consists of the usual html, a transparent image (id="placer"), and a smal script:

function showImage(src, width, height)
{
var placer = document.getElementById('placer');
placer.src = src;
placer.width = width;
placer.height = height;
}

Now the main page function becomes:

function showimageinframe(src,framename,width,height) 
{
document.frames[framename].showImage(src, width, height);
}

In fact, if you don't specify the dimensions of the placer image, then you could cut out the passing & setting of width & height, and let each image sort itself out.