Hello all !
I need help with this script :
It's a tooltip appearing onMouseOver on a link. It works fine in IE, Opera
but not Netscape 7 and Mozilla 1.5.
The tooltip sticks on the top left corner of the window.
Any help appreciated :-)
Thanks
=============== =============== ====
<script language="JavaS cript" type="text/JavaScript">
<!--
function initToolTips(){
offsetX = 0;
offsetY = 15;
ns4 = document.layers ;
ns6 = document.getEle mentById && !document.all;
ie4 = document.all;
toolTipSTYLE="" ;
if (ns4 || ns6 || ie4) {
if (ns4) toolTipSTYLE = document.toolTi pLayer;
else if(ns6) toolTipSTYLE =
document.getEle mentById("toolT ipLayer").style ;
else if(ie4) toolTipSTYLE = document.all.to olTipLayer.styl e;
if (ns4) document.captur eEvents(Event.M OUSEMOVE);
else {
toolTipSTYLE.vi sibility = "visible";
toolTipSTYLE.di splay = "none";
}
document.onmous emove = moveToMouseLoc;
}
}
//--------------------------
function moveToMouseLoc( e) {
if(ns4 || ns6) {
x = e.pageX; y = e.pageY;
} else {
x = event.x + document.body.s crollLeft;
y = event.y + document.body.s crollTop;
}
toolTipSTYLE.le ft = x + offsetX;
toolTipSTYLE.to p = y + offsetY;
return true;
}
//--------------------------
function toolTip(valItal , valGras, msg, fg, bg, police, tailleTexte) {
if(toolTip.argu ments.length < 1) { // hide
if (ns4) toolTipSTYLE.vi sibility = "hidden";
else toolTipSTYLE.di splay = "none";
} else { // show
var content =
'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg +
'"><td>' +
'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg +
'"><td align="center"> <font face="'+ police +'" color="' + fg +
'" size="' + tailleTexte + '"> \;' + msg +
' \;</font></td></table></td></table>';
if (ns4) {
toolTipSTYLE.do cument.write(co ntent);
toolTipSTYLE.do cument.close();
toolTipSTYLE.vi sibility = "visible";
}
if (ns6) {
document.getEle mentById("toolT ipLayer").inner HTML = content;
toolTipSTYLE.di splay='block'
}
if (ie4) {
document.all("t oolTipLayer").i nnerHTML=conten t;
toolTipSTYLE.di splay='block'
}
}
}
//-->
</script>
</head>
<body>
<div id="toolTipLaye r" style="position :absolute; visibility: hidden"></div>
<script language="JavaS cript">
<!--
initToolTips();
-->
</script>
<p>
<a href="javascrip t:;"
onMouseOver="to olTip('0','0',' TEXT','#000000' ,'#FFFFFF','Ari al, Helvetica,
sans-serif','2')" onMouseOut="too lTip()">Test 1</a>
</p>
I need help with this script :
It's a tooltip appearing onMouseOver on a link. It works fine in IE, Opera
but not Netscape 7 and Mozilla 1.5.
The tooltip sticks on the top left corner of the window.
Any help appreciated :-)
Thanks
=============== =============== ====
<script language="JavaS cript" type="text/JavaScript">
<!--
function initToolTips(){
offsetX = 0;
offsetY = 15;
ns4 = document.layers ;
ns6 = document.getEle mentById && !document.all;
ie4 = document.all;
toolTipSTYLE="" ;
if (ns4 || ns6 || ie4) {
if (ns4) toolTipSTYLE = document.toolTi pLayer;
else if(ns6) toolTipSTYLE =
document.getEle mentById("toolT ipLayer").style ;
else if(ie4) toolTipSTYLE = document.all.to olTipLayer.styl e;
if (ns4) document.captur eEvents(Event.M OUSEMOVE);
else {
toolTipSTYLE.vi sibility = "visible";
toolTipSTYLE.di splay = "none";
}
document.onmous emove = moveToMouseLoc;
}
}
//--------------------------
function moveToMouseLoc( e) {
if(ns4 || ns6) {
x = e.pageX; y = e.pageY;
} else {
x = event.x + document.body.s crollLeft;
y = event.y + document.body.s crollTop;
}
toolTipSTYLE.le ft = x + offsetX;
toolTipSTYLE.to p = y + offsetY;
return true;
}
//--------------------------
function toolTip(valItal , valGras, msg, fg, bg, police, tailleTexte) {
if(toolTip.argu ments.length < 1) { // hide
if (ns4) toolTipSTYLE.vi sibility = "hidden";
else toolTipSTYLE.di splay = "none";
} else { // show
var content =
'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg +
'"><td>' +
'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg +
'"><td align="center"> <font face="'+ police +'" color="' + fg +
'" size="' + tailleTexte + '"> \;' + msg +
' \;</font></td></table></td></table>';
if (ns4) {
toolTipSTYLE.do cument.write(co ntent);
toolTipSTYLE.do cument.close();
toolTipSTYLE.vi sibility = "visible";
}
if (ns6) {
document.getEle mentById("toolT ipLayer").inner HTML = content;
toolTipSTYLE.di splay='block'
}
if (ie4) {
document.all("t oolTipLayer").i nnerHTML=conten t;
toolTipSTYLE.di splay='block'
}
}
}
//-->
</script>
</head>
<body>
<div id="toolTipLaye r" style="position :absolute; visibility: hidden"></div>
<script language="JavaS cript">
<!--
initToolTips();
-->
</script>
<p>
<a href="javascrip t:;"
onMouseOver="to olTip('0','0',' TEXT','#000000' ,'#FFFFFF','Ari al, Helvetica,
sans-serif','2')" onMouseOut="too lTip()">Test 1</a>
</p>
Comment