'My function to find the x coordinate of the mouse doesn't work
I set document.body.onmousemove to the following function so that the console will log the X coordinate of the mouse on the page whenever the mouse is moved inside the body.
document.body.onmousemove = "function mouseX(e){console.log(e.clientX);}(event)";
This doesn't work. It produces no errors, but nothing happens. When I check the value of document.body.onmousemove I get null.
Note that I want to have this script injected through the JavaScript console, so I don't want html code and I would prefer not to use any JavaScript libraries either.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
