Note that there are some explanatory texts on larger screens.

plurals
  1. PODetermine initial mouse position in JavaScript?
    primarykey
    data
    text
    <p>How can I determine the initial mouse position? right now I use <code>onmousemove</code>, but that sometimes only fires when the mouse is actually moved. same with <code>onmouseover</code>.</p> <p>If I don't move the mouse, I observed the following:</p> <p>It seems like in IE a <code>mousemove</code> 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.</p> <p>The question arose because I want stuff to dangle on the cursor and I want it to hang there right from the start and not suddenly appear/jump after the first interaction.</p> <p>If the solution will be browser specific, my target is chrome.</p> <p>In case someone wants to explain to me the strange <code>mousemove</code> behavior, this is my test:</p> <pre><code>&lt;html&gt;&lt;head&gt; &lt;script type='text/javascript'&gt; window.onload = function(){ setInterval("document.getElementById('div0').innerHTML = MousePosition.x+' '+MousePosition.y;", 200) } &lt;/script&gt; &lt;script type="text/javascript" src="http://scripterlative.com/files/mousepos.j_s"&gt;&lt;/script&gt; &lt;!--&lt;script type="text/javascript" src="mousepos.j_s"&gt;&lt;/script&gt;--&gt; &lt;/head&gt;&lt;body&gt; &lt;div id="div0"&gt;&lt;/div&gt; &lt;script type='text/javascript'&gt; MousePosition.init(); &lt;/script&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>PS: you do not need to lecture me about the use of innerHTML and <code>onload</code>, this is quick and dirty on purpose.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload