views:

97

answers:

0

hi.

how can i determine the initial mouse position? right now i use onmousemove, but that sometimes only fires when the mouse is actually moved. same with onmouseover.

if i dont move the mouse, i observed the following: it seems like in IE a mousemove event is always fired right at the beginning, in firefox never, and in chrome strange enough if the script is loaded from an online location, but not if it's loaded from my local disk.

the question arose because i want stuff to dangle on the curser and i want it to hang there right from the start and not suddenly appear/jump after the first interaction.

if the solution will be browser specific, my target is chrome.

in case someone wants to explain to me the strange mousemove behavior, this is my test:

<html><head>

<script type='text/javascript'> 
window.onload = function(){
    setInterval("document.getElementById('div0').innerHTML = MousePosition.x+' '+MousePosition.y;", 200)
}
</script> 
<script type="text/javascript" src="http://scripterlative.com/files/mousepos.j_s"&gt;&lt;/script&gt; 
<!--<script type="text/javascript" src="mousepos.j_s"></script>--> 

</head><body>   

<div id="div0"></div>

<script type='text/javascript'>
MousePosition.init();
</script>

</body></html>

ps: you do not need to lecture me about the use of innerHTML and onload, this is quick and dirty on purpose.