Solved

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

Posted on 2004-04-12
4
245 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now