SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Threaded View

  1. #1
    ********* Ornithologist AtomicPenguin's Avatar
    Join Date
    May 2002
    Vancouver, BC
    0 Post(s)
    0 Thread(s)

    Getting snapshot of x,y mouse coordinates in Netscape

    Hey guys,

    I've got a little question about finding the mouse location in Netscape. I have a function which is doing a number of things, and at one point needs to capture the x,y location of the mouse. With IE it's no problem:

    x_coord = event.clientX + document.body.scrollLeft;
    y_coord = event.clientY + document.body.scrollTop;

    But with netscape, it seems you need to use the pageX and pageY (are these attributes, functions?) of the event itself - and there doesn't appear to be a generic event object like with 'event' in IE, above. After google-searching, I've found oodles of examples of finding the mouse coordinates by the rather heavy-handed method of overriding the window.onmousemove or window.onmouseclick events like so:

    window.onmousemove = move;

    function move(e) {
    x_coord = e.pageX;
    y_coord = e.pageY;

    but I just want a 'snapshot' of the co-ordinates within my function, without having to override (overload?) an actual event type like onmousemove.

    Any ideas?
    Last edited by AtomicPenguin; Aug 29, 2003 at 00:40.


Posting Permissions

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