I've done couple of research about events in javascript but still can't figure out what is being pass to event in onmousemove.
excerpt from: W3schools
onmousemove="show_coords(event)"
what is this event argument? Do I really need it? Or I could somehow make it work without the event argument like this:
onmousemove="show_coords()"
I tried everything to make it work without event argument but I think I'm missing something here.
edit:
Here's what i was playing around with.
Yes - It's working fine but I just don't understand why I need event and what is it when working with mouse coordinates
This >>> onmousemove="show_coords(event)"
To This >>> onmousemove="show_coords()" And make it work
Why does (.clientX/Y, .pageX/Y, .screenX/Y) needs the event? Is there a way to access them without it.
I tried chaging the "event" argument and every event word to "this"
Just like this >>> onmousemove="show_coords(this)"
but that doesn't work. Why?
<!DOCTYPE html>
<html onmousemove="show_coords(event)" style="border-style: solid">
<head>
</head>
<body>
<p style="position : fixed; color :red; top: 50px" id="demo"></p>
<p style="position : fixed; color :blue ;top: 10px" id="demo2"></p>
<p style="position : fixed; top: 31px" id="demo3"></p>
<div style="height: 1000px"></div>
<script>
function show_coords(event)
{
var x=event.clientX;
var y=event.clientY;
var xa=event.pageX;
var ya=event.pageY;
var xb=event.screenX;
var yb=event.screenY;
document.getElementById('demo').innerHTML = "Client: x = " + x + " y = " + y;
document.getElementById('demo2').innerHTML = "Page: xa = " + xa + " ya = " + ya;
document.getElementById('demo3').innerHTML = "Screen: xb = " + xb + " yb = " + yb;
}
</script>
</body>
</html>