General discussion

Locked

javascript and Netscape

By John Gordon ·
I am developing a simple photo gallery to place on my web site and cannot get the photos to display using Netscape.

I have the following:
A web page of thumbnails, when a thumbnail is clicked a javascript function is called with 2 arguments - anhtml filename and an image file name. The script opens the html web page in a new window. The html web page originally contains a named image comprising a single pixel.
The javascript function then changes the source of the image to the image file.

This works OK in IE but refuses to display the new image in Netscape. Why?

If anyone wants to see it I can send the bones of my code if you want to see it (it's only about 2Kb total).

Thanks

John

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

javascript and Netscape

by Jay Eckles In reply to javascript and Netscape

I don't think that NS is as liberal with the security between parent and child windows as IE is...that is, I don't think NS will let Javascript from a parent window access the DOM of a child window. Not sure about that though.

Try putting the Javascript to change the source of the image in the child window itself. You can cheat and get the name of the image to the child window by including it in the URL; this of course will go against a couple of RFCs, but it will work (probably). Something like www.server.com/child.htm?imagename.
Parse the URL and get the contents after ?.

Good luck.

Jay

Collapse -

javascript and Netscape

by John Gordon In reply to javascript and Netscape

Poster rated this answer

Collapse -

javascript and Netscape

by Shanghai Sam In reply to javascript and Netscape

I'm not quite sure why Netscape refuses to display the new image - but you might to try the following method of loading a new image in a child window.

When the user clicks on the thumbnail link, an onclick handler calls a function with one argument - an image file location. The function opens a new window and then using the document.write method, simply writes out some HMTL to the new window containing the new image.

If you look at the code below, the window.open() method allows you tospecify a document to load into the new window (here it is left blank since we want to write HTML directly to the new window), as well as a name for the new window, and you can configure the new windows' width, height, etc...

<html>

<head>
<title>test</title>

<script language="javascript">

function openDisplay(imgSrc) {
newWin = window.open('', 'test2',config='height=400,
width=400,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no,directories=no,status=no');
newWin.document.write('<html><head><title>Whatever</title></head>')
newWin.document.write('<body><img src="' + imgSrc +'"></body></html>');
}

</script>

</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">


<a href="#" onclick="javascript: openDisplay('pics/myimage.jpg');"><img name="thumb1" src="pics/thumbs/mythumb.gif" width="50" height="60" alt="Click to view full image"></a>

</body>

</html>

Check out this tutorial on the subject of opening and controlling windows:

http://www.htmlgoodies.com/beyond/openwin.html

Collapse -

javascript and Netscape

by John Gordon In reply to javascript and Netscape

Thanks that works OK

Collapse -

javascript and Netscape

by John Gordon In reply to javascript and Netscape

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums