Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script type="text/javascript">
- function getMouseXY(e) {
- if (IE) { // grab the x-y pos.s if browser is IE
- tempX = event.clientX + document.body.scrollLeft;
- tempY = event.clientY + document.body.scrollTop;
- }
- else { // grab the x-y pos.s if browser is NS
- tempX = e.pageX;
- tempY = e.pageY;
- }
- if (tempX < 0){tempX = 0;}
- if (tempY < 0){tempY = 0;}
- document.getElementById("output").innerHTML += tempX + " " + tempY + " </br>";
- return true;
- }
- function onmd() {
- document.onmousemove = getMouseXY;
- }
- function onmu() {
- document.onmousemove = null;
- }
- function divClear(){
- document.getElementById("output").innerHTML = "";
- document.onmousemove = null;
- }
- var IE = document.all?true:false;
- if (!IE) document.captureEvents(Event.MOUSEMOVE)
- var tempX = 0;
- var tempY = 0;
- //document.onmousedown = onmd;
- //document.onmouseup = onmu;
- </script>
- </head>
- <body>
- <div id="zold" onmousedown="onmd();" onmouseup="onmu();" style="width: 400px; height: 200px; background-color:green;">
- </div>
- <INPUT TYPE=BUTTON OnClick="divClear();" VALUE="Clear">
- <div id="output">
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment