javascript cursor code example
Example 1: css cursor pointer hover
.pointer {
cursor: pointer;
}
Example 2: javascript how to set cursor for whole page
document.html.style.cursor = "";
Example 3: style.cursor javascript
<p id="demo" style="cursor:wait;">Mouse over me.</p>
<script>
parag = document.getElementById("demo");
alert(parag.style.cursor);
parag.style.cursor = "crosshair";
parag.style.cursor = "help";
parag.style.cursor = "pointer";
}
</script>
Example 4: position of the mouse cursor javascript
(function() {
document.onmousemove = handleMouseMove;
function handleMouseMove(event) {
var eventDoc, doc, body;
event = event || window.event;
if (event.pageX == null && event.clientX != null) {
eventDoc = (event.target && event.target.ownerDocument) || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
event.pageX = event.clientX +
(doc && doc.scrollLeft || body && body.scrollLeft || 0) -
(doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = event.clientY +
(doc && doc.scrollTop || body && body.scrollTop || 0) -
(doc && doc.clientTop || body && body.clientTop || 0 );
}
}
})();