Solved

mouseover question-on image map, image pops up when mouse is over area

Posted on 2004-04-12
4
251 Views
Last Modified: 2008-03-10
I have a map of the US, and it is mapped so that clicking on a state will take you to another page of information, like this:

<img src="../images/northamerica.jpg" width="787" height="421" border="0" alt="" usemap="#locationmap"/>
     <map id="locationmap" name="location">

<area shape="rect" coords="28, 10, 83, 52" alt="AK"  href="the information  page." />
 
I would like to try to revamp it so that when someone's mouse is over Alaska, an image of a map of Alaska pops up. But I am pretty unacquainted with javascript, so please be very specific and simplistic for me, ok? Thanks in advance,

mel150
0
Comment
Question by:mel150
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
monolith_888 earned 125 total points
ID: 10807965
Try this code out.  This will display the images you want in a specific spot on the page upon mousing over a state.  Just alter the .stateImg class to move the location of the image that appears.  Let me know if you have any questions.

-HTH
Blake

<html>
<head>
<title>Map</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
.stateImg      {position:absolute;top:10;left:500;}
</style>
<script>
function showImg(state)
      {
      var theState = document.getElementById(state);
      theState.style.display = "";
      }
      
function hideImg(state)
      {
      var theState = document.getElementById(state);
      theState.style.display = "none";
      }
</script>
</head>
<body>
<img name="test" src="quilt.gif" width="250" height="250" border="0" usemap="#m_test" alt="">

<img id="alaska" src="alaska.gif" class="stateImg" style="display:none;">
<img id="california" src="california.gif" class="stateImg" style="display:none;">
<img id="hawaii" src="hawaii.gif" class="stateImg" style="display:none;">
<img id="florida" src="florida.gif" class="stateImg" style="display:none;">
<map name="m_test">
<area shape="rect" coords="0,133,136,250" href="alaska.html" alt="" onMouseOver="showImg('alaska');" onmouseout="hideImg('alaska')">
<area shape="rect" coords="123,0,250,137" href="california.html" alt=""  onMouseOver="showImg('california');" onmouseout="hideImg('california')">
<area shape="rect" coords="132,144,249,237" href="hawaii.html" alt=""  onMouseOver="showImg('hawaii');" onmouseout="hideImg('hawaii')">
<area shape="rect" coords="0,0,127,125" href="florida.html" alt=""  onMouseOver="showImg('florida');" onmouseout="hideImg('florida')">
</map>
</body>
</html>
0
 

Author Comment

by:mel150
ID: 10808604
Hi-I'm not stalling on accepting this, just trying to make sense of it before I start. I'm sure I'll have a few question for yu soon, though. Thanks-it looks awesome.
0
 

Author Comment

by:mel150
ID: 10808750
You javascript guys! Just like magicians! Thanks, it worked like a charm.

Mel150
0
 
LVL 4

Expert Comment

by:monolith_888
ID: 10808840
Glad to help!

-blake
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question