Image Map

Hi There,
This is probably very simple but only when you know how!

The following code works perfectly with IE, but doesn't work with Netscape.

Why??

  <SCRIPT Language="JavaScript">
<!--
start = new Image()
start.src = "images/starters.gif"
main = new Image()
main.src= "images/maincourse.gif"
dessert = new Image()
dessert.src = "images/dessert.gif"

function menuStart() {
document.menu.src = start.src;
}

function menuMain() {
document.menu.src = main.src;
}

function menuDessert() {
document.menu.src = dessert.src;
}
-->
  </SCRIPT>
</HEAD>
<BODY  BGCOLOR="#b99d80">

<map name="menumap">
<area shape="rect" coords="11,16,165,50" href="JavaScript: menuStart()">
<area shape="rect" coords="166,15,365,53" href="JavaScript: menuMain()">
<area shape="rect" coords="366,18,514,49" href="JavaScript: menuDessert()">
</map>

<P><CENTER><IMG SRC="images/starters.gif" NAME="menu" WIDTH="530" HEIGHT="1000"
ALIGN="BOTTOM" BORDER="0" NATURALSIZEFLAG="3" USEMAP="#menumap"></CENTER>

</BODY>
</HTML>
muttley1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
For NS you must refer to the images array (should also work in IE):

function menuStart() {
    document.images['menu'].src = start.src;
}

function menuMain() {
    document.images['menu'].src = main.src;
}

function menuDessert() {
    document.images['menu'].src = dessert.src;
}
0
muttley1Author Commented:
Thanks for the rapid response!
I tried using the method you suggested.
Again it worked fine with IE but it didn't with Netscape.
On thing I did notice though is the cursor changes on mousing over the hotspots. It just doesn't run the function.

It can't be that far away!
0
knightEknightCommented:
Hmm, how about this:

<area shape="rect" coords="11,16,165,50" onClick="menuStart()">
<area shape="rect" coords="166,15,365,53" onClick="menuMain()">
<area shape="rect" coords="366,18,514,49" onClick="menuDessert()">
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

muttley1Author Commented:
Adjusted points to 150
0
muttley1Author Commented:
Nope!
Again works great with IE but not Netscape.
Also, the cursor doesn't change moving over the hotspots like last time.

I'm pushing it up to 150 points!

Help!!
0
knightEknightCommented:
Ah, that's because I left out the href.  I admit, I'm guessing here because I can't test this:

<area shape="rect" coords="11,16,165,50" href="#"  onClick="menuStart();return(false);">
<area shape="rect" coords="166,15,365,53" href="#" onClick="menuMain();return(false);">
<area shape="rect" coords="366,18,514,49" href="#" onClick="menuDessert();return(false);">
0
knightEknightCommented:
... or better than  "#"  is  "javascript:;"
0
muttley1Author Commented:
Thanks again but.....

It works fine with IE, not with Netscape.
(I'm beginning to sound like a stuck record!)
Now the cursor changes while mousing over the hotpoints but onClick doesn't run the functions.
I just get a little egg timer for a few seconds. No JavaScript errors either!

Any other ideas?
0
us111Commented:
yes I think just add
// before  -->

function menuDessert() {
                      document.menu.src = dessert.src;
                      }
// -->
</SCRIPT>

netscape will return an Error if you forgot the //
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
muttley1Author Commented:
Thank's us111,
Problem solved!
I won't forget that one in a hurry.
0
us111Commented:
thx for you 150 points
0
muttley1Author Commented:
you're welcome :-)
0
knightEknightCommented:
I wouldn't have seen that in a million years  :)

But I am wondering if NS works with the functions as posted above:

function menuDessert() {
  document.menu.src = dessert.src;
}

.... or did you have to do this?:

function menuDessert() {
  document.images['menu'].src = dessert.src;
}
0
muttley1Author Commented:
It works with both.
I use the function:

function menuDessert() {
                 document.menu.src = dessert.src;
               }
 often with mouse overs to change images.

I can't believe that // could make such a difference!

Thanks for trying anyway. I'm sure this isn't the last you've heard of me here. It's a great site.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.