Welcome to WebmasterWorld Guest from 54.167.82.170

Forum Moderators: open

Message Too Old, No Replies

mouseover/img map problem

Is there a js programmer around?

     

antipodes

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

10+ Year Member



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>

DrDoc

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

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



Which browser causes you problems?

DrDoc

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

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



And, actually, what exactly is the problem? :)

ShawnR

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

WebmasterWorld Senior Member 10+ Year Member



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

BlobFisk

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

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




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!

antipodes

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

10+ Year Member



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

tedster

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

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



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?

antipodes

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

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month