mouse coordinates in javascript? -



mouse coordinates in javascript? -

i created little function mouse coordinates in div somehow not working. checked function thoroughly didn't find bug.

<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title></title> <script type="text/javascript"> function setvalues() { var s = "x:" + window.event.clientx + " y:" + window.event.clienty ; document.getelementbyid('divcoord').innerhtml = s; } </script> </head> <body onmousemove=setvalues()> <div id="divcoord"></div> </body> </html>

the window.event property nowadays in net explorer, , in versions think. in fact, entire operation trying requires advanced cross-browser coding.

i suggest consider using javascript framework normalizes events, such jquery.

using jquery, , work in browsers:

$(document).mousemove(function(e) { $('#divcoord').html('x:' + e.pagex + ' y:' + e.pagey); });

javascript

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -