Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't my JavaScript work in Netscape - it's fine in IE

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
Hi,

I've had help writing this code so I can't claim to know much about it, but it works fine in IE but not in Netscape. Basically, when a user clicks on a thumbnail it opens an image in a new window.

This is my script:

<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot;>
<!-- BEGIN
function openWin(Nimg, url, imgref, imgwidth, imgheight)
{
myNewWin = window.open('', '', 'scrollbars=yes,resizable=yes,top=0,screenY=0');
myDoc = myNewWin.document;
myDoc.write(&quot; ... HTML code of new window goes here ... &quot;);
}

function openImg(url, imgref, imgWidth, imgHeight)
{
Nimg = new Image();
Nimg.src = url;
Nimg.onLoad = openWin(Nimg, url, imgref, imgWidth, imgHeight)
}

END -->
</SCRIPT>

...and this is how I call it:

<a href='javascript:void(0)' onclick=&quot;openImg('./bigpic1.jpg', 'bigpic1', '1024', '768')&quot;>1024x768</a>

If it helps to see the page in action, go to:


(for example)

Thanks in advance.


- Andy
_______________________________
&quot;On a clear disk you can seek forever&quot;
 
Hi,
I don't claim to know Javascript either, but I use the following code along with the IMG SRC so that when clicked a new window opens in a specific spot on the page and of a specific size. Very simple, no other Javascript in the head section needed. Maybe this could work for you? The width, height, left, & top values you can change to suit how big and where you want your window to be. To be honest, I'm not sure if Netscrap gets this, but I've never had anyone say they had a problem with my site.

href=&quot;newWindowURL&quot; onClick=&quot;window.open('filename.html','nameOfWindow','width=800,height=600,
left=400,top=250');return false&quot;>
 
I hate to say this, but I would consider totally scrapping the two JavaScript functions you have, as they aren't really necessary, and only make the code more confusing for users such as myself.

The code Pixelchik gave would work just fine. For example, I changed one of your links to:

<a href=&quot;&quot; onclick=&quot;window.open(' 'jolie1', 'width=1024', 'height=768');return false;&quot;>1024x768</a>

and it opened just fine in both IE and Mozilla/Netscape.

I don't know everything about JavaScript, but I do know there are slight differences across browsers.
 
Thanks guys, I'll try these suggestions when I get back to the right computer.

- Andy
_______________________________
&quot;On a clear disk you can seek forever&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top