Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

position of the mouse cursor javascript

(function() {
    document.onmousemove = handleMouseMove;
    function handleMouseMove(event) {
        var eventDoc, doc, body;

        event = event || window.event; // IE-ism

        // If pageX/Y aren't available and clientX/Y are,
        // calculate pageX/Y - logic taken from jQuery.
        // (This is to support old IE)
        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 );
        }

        // Use event.pageX / event.pageY here
    }
})();
Comment

PREVIOUS NEXT
Code Example
Javascript :: alert javascript 
Javascript :: How to update one mongoose db 
Javascript :: javascript update value when slider moves javascript 
Javascript :: animate change of class angular 
Javascript :: import all images from folder react 
Javascript :: findone and update mongoose 
Javascript :: javascript array methods 
Javascript :: js promise 
Javascript :: javascript color green to red 
Javascript :: change events 
Javascript :: edit embeds discord.js 
Javascript :: strict mode 
Javascript :: open ai gym 
Javascript :: functional component react 
Javascript :: js check if map contains key 
Javascript :: for...of Syntax 
Javascript :: chnage classname of div 
Javascript :: react-data-table-component cell action stack overflow 
Javascript :: passing data between components in react js 
Javascript :: how to run the sonar scanner 
Javascript :: substr javascript 
Javascript :: jest express testing 
Javascript :: react: fow to use find(to get the id of a element 
Javascript :: toggle 
Javascript :: javascript player movement 
Javascript :: generate qr code react 
Javascript :: filter js object array based on multiple parameters 
Javascript :: export json / array to excel in javascript 
Javascript :: pass data ino pug nodejs 
Javascript :: next js get gurrent page params 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =