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

Q1259 How can I combine tool tips with an image map, but have the tool tips hover at the same place as the mouse pointer?

irt.org | Knowledge Base | DHTML | Q1259 [ previous next ]

Q1259 How can I combine tool tips with an image map, but have the tool tips hover at the same place as the mouse pointer?

Try:

<script type="text/javascript" language="JavaScript"><!--
function showAt(e,object) {
    var x=y=0;

    if (document.layers && document.layers[object] != null) {
        document.layers[object].left = e.pageX;
        document.layers[object].top = e.pageY;
        document.layers[object].visibility = 'visible';
    }
    else if (document.all) {
        document.all[object].style.posTop = window.event.x;
        document.all[object].style.posLeft = window.event.y;
        document.all[object].style.visibility = 'visible';
    }
}

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

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

<map name="image-map">
<area shape="rect" coords="15,15,85,85" href="javascript:alert('1')"
    onMouseover="if (window.event || document.layers) showAt(event,'myLayer1'); else showAt('','myLayer1')"
    onMouseout="hide('myLayer1')"
>
<area shape="rect" coords="93,15,110,85" href="javascript:alert('2')"
    onMouseover="if (window.event || document.layers) showAt(event,'myLayer2'); else showAt('','myLayer2')"
    onMouseout="hide('myLayer2')"
>
<area shape="circle" coords="150,50,35" HREF="javascript:alert('3')"
    onMouseover="if (window.event || document.layers) showAt(event,'myLayer3'); else showAt('','myLayer3')"
    onMouseout="hide('myLayer3')"
>
</map>


<img name="boxImage" src="white.gif" border=0 width=200 height=100 usemap="#image-map">


<div id="myLayer1" class="myStyle">
<table bgcolor="#ffffcc"><tr><td>
This text is hidden from view.
<br>
It is revealed when the mouse
<br>
moves over the first hot spot
</td></tr></table>
</div>

<div id="myLayer2" class="myStyle">
<table bgcolor="#ffffcc"><tr><td>
This text is also hidden from view until it is
revealed when the mouse moves over the 2nd hot spot
</td></tr></table>
</div>

<div id="myLayer3" class="myStyle">
<table bgcolor="#ffffcc"><tr><td>
Some more text which is also hidden from view until it is
revealed when the mouse moves over the 3rd hot spot
</td></tr></table>
</div>

Ian Ornstein writes:

Suggested changes in example. In Internet Explorer 5 it works without the table. Changes:

<style><!--
.myStyle {
  position : absolute;
  visibility: hidden;
  background-color: "#ffffcc";
}
//--></style>

<div id="myLayer1" class="myStyle">
This text is hidden from view.
<br>
It is revealed when the mouse
<br>
moves over the first hot spot
</div>

<div id="myLayer2" class="myStyle">
This text is also hidden from view until it is
revealed when the mouse moves over the 2nd hot spot
</div>

<div id="myLayer3" class="myStyle">
Some more text which is also hidden from view until it is
revealed when the mouse moves over the 3rd hot spot
</div>

Feedback on 'Q1259 How can I combine tool tips with an image map, but have the tool tips hover at the same place as the mouse pointer?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


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