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!

Netscape problems with JS in HREF

Status
Not open for further replies.
Jan 8, 2002
23
US
Hi,

I am attempting to use frames in a website, but run into problems with NN47 and NN60. I have images on one frame that, when clicked, will change the webpage in the other frame. Should be pretty simple, right?

Everything would be fine, but NN47 doesn't recognize ONCLICK methods within an image. Therefore the following code won't work on NN47 (but will on IE and NN6):

<img src=&quot;whatever.gif&quot; onclick=&quot;return myjscode()&quot; id=&quot;whatever&quot; width=&quot;20&quot; height=&quot;20&quot;>

So now I need to use <A HREF=&quot;&quot;> tags around the image as such, because NN47 recognizes this:

<a href=javascript: onclick=&quot;return myjavascript()&quot;><img src=&quot;whatever.gif&quot; id=&quot;whatever&quot; width=&quot;20&quot; height=&quot;20&quot;></a>

The JavaScript code that gets called is

function myjavascript()
{
window.parent.frameb.location.href = &quot;mywebpage.htm&quot;
return true;
}


My problem with this is that with NN47, the COMMUNICATOR CONSOLE always pops up! NN47 performs the JavaScript well, but I can't stop the COMMUNICATOR CONSOLE from appearing. I can only assume this is what will happen to all NN4x browsers.

My other problem is with NN6. The image with the onclick event running the JavaScript is in FrameA. FrameA disappears each time the onclick method is run, although it DOES update FrameB with the correct web page. If I put an 'alert(&quot;&quot;)' command before 'return true;', then FrameA does not disappear. This must be a bug with NN6, but surely people use type of code in their websites. I can not believe such simple code has so many problems.

Any ideas?

Thanks,

Jon
 
I'm not really sure you need to use javascript at all for changing the page of another frame. Typically you give the frames names, such as &quot;menu&quot; and &quot;main&quot;, by having a command like

<FRAME SRC=&quot;homepage.html&quot; NAME=&quot;main&quot; MARGINWIDTH=&quot;0&quot; MARGINHEIGHT=&quot;0&quot; NORESIZE>

and use a linking statement in your menu page such as

<a href=&quot;mywebpage.html&quot; target=&quot;main&quot;><img src=&quot;whatever&quot;></a>

I believe this works with both ie and metscape.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top