Click to See Complete Forum and Search --> : Setting Document image source not working in netscape


dlmoak
01-22-2004, 07:25 PM
The following code is tied to an thumbnail image. When clicked, a specified window should open and use the indicated image (a larger version of the thumbnail) as the document image. It works fine in IE6, but in Netscape 7, the document opens, but without the image. Any suggestions?

<img src="../images/Ads/tnails/1886_01.jpg" width="52" height="29" border="1" onClick="win1=open('advert.htm','winname','scrollbars,resizable');
win1.document.the_image.src='../images/Ads/1886_01.jpg';">

The OnClick event opens 'advert.htm' naming it 'win1' - then specifies the document image source.

Thanks

gil davis
01-22-2004, 09:50 PM
Any suggestions?
Put the right image in the file to begin with ;)

You have set yourself up for a race condition. Browsers usually try to launch a load process and then return to execute the next JS statement. The document probably does not yet exist for NS7 when it attempts to find the image. If you open the javascript console, you will probably see an error indicating that the image object does not exist or has no properties.

IE 6 will probably fail if the page is moved to a slow machine. The only way to guarantee that it will work under all circumstances is to not try to change the image until you are sure the page has loaded. You could use the onload event for the new window.

I think I like my first suggestion better...

dlmoak
01-22-2004, 10:53 PM
Well, the point is that there are 185 thumbnails and I want to control how the window looks that presents the larger image without having to make 185 pages.:)

Pittimann
01-23-2004, 12:56 AM
Hi!

What about document writing the stuff into a blank window?

Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var doc1='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'
var doc2='</title></head><body>';
var doc3='</body></html>'
function openPopup(img,imgtitle,desc){
win1=window.open('','winname','scrollbars,resizable');
win1.document.write(doc1+imgtitle+doc2);
win1.document.write(desc+'<br><br>');
win1.document.write('<img src="'+img+'" border=0>');
win1.document.write(doc3);
win1.document.close();
}
//-->
</script>
</head>
<body>
<img src="../images/Ads/tnails/1886_01.jpg" width="52" height="29" border="1" onClick="javascript:openPopup('../images/Ads/1886_01.jpg','1886','Nice image:')">
</body>
</html>

Please note: in the onClick="" java and script have to be one word...

Cheers - Pit

dlmoak
01-23-2004, 06:29 AM
Thanks, PHP - I'll give it a try. Unfortunately I'm headed out the door until Sunday night so it will have to wait.