Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-12
4
Medium Priority
?
259 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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

916 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