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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I occasionally dabble in Javasc

Status
Not open for further replies.

bearsite4

Programmer
Sep 29, 2001
79
AU
Hi, I occasionally dabble in Javascript and I've run into a problem. I've got an onMouseOver and onMouseOut event handler for my images. The problem is that the mouseover doesn't work with Netscape (6 or 4.x). It works with IE and Opera though. Does anyone know what might be the problem? Do I have to return true for any of the events. I tried this but it didn't make a difference.
 
Are you sure your events aren't firing? Maybe it is just what you're trying to do in the event handlers, and not a problem with the events.

The most basic tool in your debugging kit (stone knife) is alert(). Put alert('got here #1'), alert('got here #2'), etc. in your javascript to determine whether or not things are happening.

Otherwise we'll have to see some code or hear more about how you're implementing your rollovers.
 
Thanks for your tips. Now that I know Netscape should work, I'm sure I'll perservere and fix up my script. I was just wondering though, why the script would work on IE6 and Opera5 but not Netscape.
 
It's still not working and driving me crazy. Here's the code, as I'm new I wouldn't mind any helpful advice, criticism etc.

//cacheimg.js

HomeAlt = new Image();
HomeAlt.src = "images/Homeb_a.gif";
LinksAlt = new Image();
LinksAlt.src = "images/Linksb_a.gif";
DownloadsAlt = new Image();
DownloadsAlt.src = "images/Downloadsb_a.gif";

function on( image )
{
if( image == "home" )
Home.src = HomeAlt.src;
else if( image == "links" )
Links.src = LinksAlt.src;
else if( image == "downloads" )
Downloads.src = DownloadsAlt.src;
}

function off( image )
{
switch( image )
{
case "home": Home.src = "images/homeb.gif"; break;
case "links": Links.src = "images/linksb.gif"; break;
case "downloads": Downloads.src = "images/downloadsb.gif"; break;
}
}

By the way, as you've noticed I haven't gotten around to updating my off function which also happens to illustrate one of my questions. With opera, ie you can use strings in switch but netscape doesn't seem to recognise it. IS this correct?
 
By the way, this is how I call it.

<a href=&quot;index.html&quot;><img src=&quot;images/homeb.gif&quot; name=&quot;Home&quot; alt=&quot;home&quot; border=0 onMouseOver=&quot;on('home')&quot; onMouseOut=&quot;off('home')&quot;></a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top