Hello,
I'm trying to make different tooltips appear as the mouse moves over the various options of a select. I found a slick method for doing so in mozilla-based browsers, but IE chokes on it.
Any help for making this work in IE would be very much appreciated.
Here's the code I found:
Thanks in advance,
jj
I'm trying to make different tooltips appear as the mouse moves over the various options of a select. I found a slick method for doing so in mozilla-based browsers, but IE chokes on it.
Any help for making this work in IE would be very much appreciated.
Here's the code I found:
Code:
<HEAD>
<STYLE>
#tooltip {
position: absolute;
visibility: hidden;
border: 1px solid black;
background-color: lightyellow;
}
</STYLE>
<SCRIPT>
var descriptions = {
'1': 'This is number 1.',
'2': 'This is number 2.',
'3': 'This is number 3.'
}
function showTooltip (nextTo, tip) {
var tt = document.getElementById('tooltip');
tt.innerHTML = descriptions[tip];
tt.style.left = (getPageLeft(nextTo) + nextTo.offsetWidth) + 'px';
tt.style.top = getPageTop(nextTo) + 'px';
tt.style.visibility = 'visible';
}
function hideTooltip () {
document.getElementById('tooltip').style.visibility = 'hidden';
}
function getPageLeft (el) {
var left = 0;
do
left += el.offsetLeft;
while ((el = el.offsetParent));
return left;
}
function getPageTop (el) {
var top = 0;
do
top += el.offsetTop;
while ((el = el.offsetParent));
return top;
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID="tooltip"></DIV>
<SELECT ID="aSelect"
ONMOUSEOVER="showTooltip(this, event.target.value)"
ONMOUSEOUT="hideTooltip();"
>
<OPTION VALUE="1">1
<OPTION VALUE="2">2
<OPTION VALUE="3">3
</SELECT>
</BODY>
jj
Comment