Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1724 How can I dynamically display text underneath an image using an image map and on mouse over events?

irt.org | Knowledge Base | JavaScript | DHTML | Q1724 [ previous next ]

Q1724 How can I dynamically display text underneath an image using an image map and on mouse over events?

Try the following which works in Netscape Navigator 4, Internet Explorer 4+ and Netscape Navigaotr 6+:

<html>

<head>

<style type="text/css"><!--
.absolute  { position:absolute; visibility:hidden; }
//--></style>

<script language="JavaScript"><!--
function show(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'visible';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'visible';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'visible';
  }
}

function hide(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'hidden';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'hidden';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'hidden';
  }
}
//--></script>

</head>

<body>

<map name="image-map1">
<area shape="rect" coords="15,15,85,85"  href="default.htm" onMouseover="show('myDiv')" onMouseout="hide('myDiv')">
<area shape="rect" coords="93,15,110,85" href="default.htm" onMouseover="show('myDiv')" onMouseout="hide('myDiv')">
<area shape="circle" coords="150,50,35"  href="default.htm" onMouseover="show('myDiv')" onMouseout="hide('myDiv')">
</map>

<img src="image.gif" border="0" width="200" height="100" usemap="#image-map1"> 

<div id="myDiv" class="absolute" style="width:200;">
<p>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem
accusantium doloremque laudantium, totam rem aperiam, eaque ipsa ab
illo inventore veritatis et quasi architecto beatae vitae dicta sunt
explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut
odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
voluptatem sequi nesciunt.  Neque porro quisquam est qui do lorem
ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia
nonnumquam eiusmodi tempora incidunt ut labore et dolore magnam
aliquam quaerat voluptatem.
</p>
</div>

</body>

</html>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.