Hi Sid,
Here's an example Javascript that I'm using that moves a hidden DIV to the
location of the cursor and makes the DIV visible while the mouse is hovering
over a SPAN element:
====== Hidden DIV ======
<div id=divWinMsg style="BORDER-RIGHT:black 2px solid;
BORDER-TOP:black 2px solid; LEFT:300px; VISIBILITY:hidden;
FONT:10pt comic sans ms; BORDER-LEFT:black 2px solid;
WIDTH:200px; PADDING-TOP:7px; BORDER-BOTTOM:black 2px solid;
POSITION:absolute; TOP:800px; HEIGHT:120px;
TEXT-ALIGN:center; z-index:1; background-image:
url('images/winmsg_back.gif'); " />
====== Call to Javascript =======
<span id="win1" onmouseover="richToolTip('Test Message',event);"
onmouseout="hideToolTip();" ><img src=images/awesome.gif height=35 width=35
/></span>
====== Javascript =======
<SCRIPT language=JavaScript>
function richToolTip(WinMsg, e)
{
var xCoord = 0;
var yCoord = 0;
var oScreenWidth = 0;
var oScreenHeight = 0;
var myElement;
if (document.layers)
{
// old Netscape versions
myElement = document.divWinMsg;
if ((myElement == null) || (myElement == "undefined"))
{ myElement = document.getElementById('divWinMsg'); }
oScreenWidth = window.innerWidth;
oScreenHeight = window.innerHeight;
xCoord = e.pageX + 15;
yCoord = e.pageY + 15;
if (xCoord + 200 + 5 > oScreenWidth)
{ xCoord = xCoord - 225; }
if (yCoord + 120 + 15 > oScreenHeight)
{ yCoord = yCoord - 150; }
}
else
{
// IE and newer versions of Netscape
myElement = document.getElementById('divWinMsg');
if (myElement != null && myElement != "undefined")
{
oScreenWidth = document.body.clientWidth;
oScreenHeight = document.body.clientHeight;
xCoord = e.clientX + document.body.scrollLeft +
document.documentElement.scrollLeft + 15;
yCoord = e.clientY + document.body.scrollTop +
document.documentElement.scrollTop + 15;
if (e.clientX + 200 + 5 > oScreenWidth)
{ xCoord = xCoord - 225; }
if (e.clientY + 120 + 15 > oScreenHeight)
{ yCoord = yCoord - 150; }
}
}
if (xCoord != 0 && yCoord != 0 && myElement != null && myElement !=
"undefined")
{
myElement.innerHTML = WinMsg;
if (document.layers)
{
if (typeof myElement.style.top != 'number')
{ eval("myElement.moveTo(xCoord, yCoord)"); }
else
{ myElement.style.top = yCoord;
myElement.style.left = xCoord; }
if ((myElement.style.visibility == null) ||
(myElement.style.visibility == "undefined"))
{ myElement.visibility = 'visible'; }
else
{ myElement.style.visibility = 'visible'; }
}
else
{
myElement.style.top = yCoord;
myElement.style.left = xCoord;
myElement.style.visibility = 'visible';
}
}
}
function hideToolTip()
{
if (document.layers)
{
// old Netscape versions
var myElement = document.divWinMsg;
if ((myElement == null) || (myElement == "undefined"))
{ myElement = document.getElementById('divWinMsg'); }
if ((myElement.style.visibility == null) ||
(myElement.style.visibility == "undefined"))
{ myElement.visibility = 'hidden'; }
else
// IE and newer versions of Netscape
{ myElement.style.visibility = 'hidden'; }
}
else
{ document.getElementById('divWinMsg').style.visibility = 'hidden'; }
}
</SCRIPT>