<html>
<script language="javascript">
document.onmousemove=function(evt) {
evt = (evt || event);
document.getElementById('x').value = evt.clientX;
document.getElementById('y').value = evt.clientY;
document.getElementById('a').style.left = evt.clientX;
document.getElementById('a').style.top = evt.clientY;
}
$('.test').disableSelection();?
</script>
<body style="cursor: none;">
<input type="text" id="x"></input><br>
<input type="text" id="y"></input>
<div id="a" style="height: 3px; width: 3px; background-color: green; border-radius: 3px; position: absolute;"></div>
<div id="b" class="test" style="position: absolute; top: 0px; left: 0px; height: 100%; width: 100%;"></div>
</body>
</html>
This is the code I’m using. Now, if you try to use this code in your browser (I use Google Chrome or Firefox), you will notice that the green dot isn’t following the cursor coordinates.
The dot will only follow the cursor if you remove all the other javascript code except for the ones you use to locate the cursor and to place the dot.
I have tried to locate the cursor with many other code and I also tried to use this code in combination with other javascript code but every time I tried, it doesn’t work with other Javascript code in the file.
Then I tried to seperate the Javascript code in to different files:
<script language="javascript" src="loccur.js"></script>
<script language="javascript" src="disabletext.js"></script>
and it gave the same result.
I hope someone can help me to use this cursor-location-code or a similar one in combination with other javascript code.
Works fine for me in chrome if you remove the ‘?’ at the end of line 10