SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    To Catch Mouse Positions in Javascript COde

    How to catch the current mouse positions in onmousedown event of a body tag.
    For IE we can use event object.....
    But for mozilla browser its not working....

    Please help me on this.

    Thanks & Regard
    Adil

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    See http://javascript.about.com/library/blmousepos.htm for cross browser routines to get the cursor position.

    Only JScript provides window.event to pass events, JavaScript passes it as a parameter on the call so where you have a function that is called where you need to process the event that triggered it you define the function as:

    Code:
    function doSomething(e) {
    e = {window.event) ? window.event : e;
    var X = mouseX(e);
    var Y = mouseY(e);
    ....
    }
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •