ir_thom
05-07-2009, 11:07 AM
I am using Javascript to create tooltips. When I used the mouse wheel to scroll down the page the tooltips would go up vertically and were not placed next to cursor. This happened in IE8 and FF but did not happen in Chrome. I did a little bit of Googling and as a result changed the position: absolute; to position: fixed; This solved the problem in IE8 and FF, but now the problem appears in Chrome. This is the JS used for the tooltip:
style>
<style type="text/css">
<!--
#toolTipBox {
display: none;
padding: 0px;
font-size: 10px;
border: black solid 3px;
font-family: arial;
position: absolute;
background-color: #000000;
color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Saul Salvatierra :: http://myarea.com.sapo.pt
with help from Ultimater :: http://ultimiacian.tripod.com */
var theObj="";
function toolTip(text,me) {
theObj=me;
theObj.onmousemove=updatePos;
document.getElementById('toolTipBox').innerHTML=text;
document.getElementById('toolTipBox').style.display="block";
window.onscroll=updatePos;
}
function updatePos() {
var ev=arguments[0]?arguments[0]:event;
var x=ev.clientX;
var y=ev.clientY;
diffX=24;
diffY=0;
document.getElementById('toolTipBox').style.top = y-2+diffY+document.body.scrollTop+ "px";
document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
theObj.onmouseout=hideMe;
}
function hideMe() {
document.getElementById('toolTipBox').style.display="none";
}
Does Chrome deal with positioning differently? Any help would be greatly appreciated.
style>
<style type="text/css">
<!--
#toolTipBox {
display: none;
padding: 0px;
font-size: 10px;
border: black solid 3px;
font-family: arial;
position: absolute;
background-color: #000000;
color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Saul Salvatierra :: http://myarea.com.sapo.pt
with help from Ultimater :: http://ultimiacian.tripod.com */
var theObj="";
function toolTip(text,me) {
theObj=me;
theObj.onmousemove=updatePos;
document.getElementById('toolTipBox').innerHTML=text;
document.getElementById('toolTipBox').style.display="block";
window.onscroll=updatePos;
}
function updatePos() {
var ev=arguments[0]?arguments[0]:event;
var x=ev.clientX;
var y=ev.clientY;
diffX=24;
diffY=0;
document.getElementById('toolTipBox').style.top = y-2+diffY+document.body.scrollTop+ "px";
document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
theObj.onmouseout=hideMe;
}
function hideMe() {
document.getElementById('toolTipBox').style.display="none";
}
Does Chrome deal with positioning differently? Any help would be greatly appreciated.