XMPP JavaScript Library

Get Mouse Position on web page Using Java Script

JavaScript, Sachin Puri, 2010-04-25 22:02:00

<HTML>
 <HEAD>
  <TITLE>Get Mouse Position on web page Using Java Script</TITLE>
  <script>
    function get_mouse_position(evt)
    {
        var explorer=navigator.userAgent.toLowerCase();
   
        if(explorer.indexOf("msie")>-1)//For Internet Explorer
        {
            document.getElementById('txt').value="X: " + evt.x + " Y: " + evt.y;
        }
        else//For Firefox
        {
            document.getElementById('txt').value="X: " + evt.pageX + " Y: " + evt.pageY;
        }
    }
  </script>
 </HEAD>

 <BODY onMouseMove="get_mouse_position(event)">
  Mouse Position: <input id="txt" type="text" name="mouse position"/>
 </BODY>
</HTML>

Add Your Comment
   
    Yes! I want to receive all comments by email

  by industrial training indore on 03-Jul-2012 11:06 am
Hello there I am so delighted I found your blog page, I really found you by mistake, while I was researching for something else, Regardless I am here now and would just like to say many thanks for a remarkable post and a all round enjoyable blog.Please do keep up the excellent work. industrial training indore
  • Reply
  •  1 Like
  •  0 Dislike
  • Report