Welcome to WebmasterWorld Guest from 54.160.221.82

Forum Moderators: open

Message Too Old, No Replies

mouseover/img map problem

Is there a js programmer around?

     
2:09 pm on Apr 14, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 30, 2002
posts:71
votes: 0


Hello all

I have a problem with this script. I've searched all over for the correct syntax to fit this type of script with no success. I can't see what's up with it. Can you help?

It's to do with syntax, not the map tags or any other thing that obvious. I've been swapping tags around and this is whjere I've had enough of it.

The script:
<html>
<head>
<title>Image swap</title>
<script language="JavaScript" type="text/javascript">
<!-- hide
if(document.images){
   net0=new Image();
   net0.src="images/net0.gif";
   cell=new Image();
   cell.src="images/netcell.gif";
jack=new Image();
   jack.src="images/netjack.gif";
max=new Image();
   max.src="images/netmax.gif";
simm=new Image();
   simm.src="images/netsimm.gif";
}
else {
   net0="";
   netcell="";
netjackl="";
netmax="";
netsimm="";
   document.button="";
}
function myVoid() {;}
// end hide --> </script>
</head>
<body>

<a href="javascript:myVoid" onMouseover="document.button.src=cell.src" onMouseout="document.button.src=net0.src">
<img src="images/net0.gif" width="408" height="360" border="0" usemap="#thismap"
name="button"></a>
<map name="thismap"><area alt="netcel" coords="22,100,92,130">
</map>

<area alt="netcel" coords="320,187,400,211" href="javascript:blank()"
onMouseover="document.button.src=cell.src" onMouseout="document.button.src=net0.src">

<area alt="netcel" coords="48,276,124,303" href="javascript:blank()"
onMouseover="document.button.src=cell.src" onMouseout="document.button.src=net0.src">

<area alt="netcel" coords="256,282,334,310" href="javascript:blank()"
onMouseover="document.button.src=cell.src" onMouseout="document.button.src=net0.src">

</map>

</body>
</html>

2:16 pm on Apr 14, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


Which browser causes you problems?
2:19 pm on Apr 14, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


And, actually, what exactly is the problem? :)
2:30 pm on Apr 14, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 27, 2003
posts:664
votes: 0


DrDoc is right that symptoms would make it easier to diagnose. In the absense of those... my first suggestion would be to change some of the variable names so they don't overide built-in elements. The two I can spot are:

max() is a Javascript function
<button> is an html tag.

Shawn

2:46 pm on Apr 14, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0



a href="javascript:myVoid"

Try javascript:void(); or if you want to use your function javascript:myVoid();.

Also, use only type="text/javascript" - the language attribute is deprecated.

ShawnR got the other possible problems, and DrDoc is spot on - without the symptoms we are just guessing!

2:41 am on Apr 15, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 30, 2002
posts:71
votes: 0


the symptoms are:

The mouseover simply isnt working. Though it did click it would not mouseover.

In short, nothing happens when I mouseover. (But strange that it will click to the swap image).

Im using IE5.1 and a Mac. But I can mouseover elsewhere so i assume it isnt the browser. I'll make the changes suggested to see if there is any fix in this, and post a reply

3:24 am on Apr 15, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


I know you said that it wasn't the image map, but the code you posted has two </map> tags - the image map is being closed too soon.

In general the combination of image maps and mouseover behavior is a gnarly one. Why not slice your image and do straightforard anchor tags with mouseovers?

1:08 pm on Apr 15, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 30, 2002
posts:71
votes: 0


thanks for all your help.

I fixed this after discovering the document.path wasnt working (on IE/Mac at least).

If anyone wants to see this finished i can sticky it.

There may be other changes ive made in this script.