SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast lauriek's Avatar
    Join Date
    Dec 2002
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Detect browser window move

    I'm aware that I can stick this into my body element and detect browser window resize;

    Code:
    <body onResize='callfunction()'>
    And I've read on a web page that there is move event handler, and the implication was that I should be able to do something like;

    Code:
    <body onMove='callfunction()'>
    But in testing this does not work.

    Is this possible, and if so what am I doing wrong? (For initial testing I'm using FF latest release).

  2. #2
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a hunch, but you might be able to capture the document.mousemove event --- then each time your custom function is called you check the x,y coordinates of the window against the original x,y coordinates.

    If figure in order to move a window, the mouse has to be used, thus capturing the mouse event handler and comparing the old x,y to the windows current x,y coordinates should work. THe screenX, screenY properties hold the x,y coordinates relative to the users screen. If the new window coordinates are not the same as the original coordinates then move the window back.

    This might work well capturing the mouse release as well.

    Again, just a hunch.
    intragenesis, llc professional web & graphic design

  3. #3
    SitePoint Enthusiast lauriek's Avatar
    Join Date
    Dec 2002
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that! It didn't quite work, as it doesn't seem to capture mouse events that happen on the window title bar, only events /within/ the window/document body.

    However I modified this idea; I setup an interval timer, so ever 5 seconds a script runs which compares the window position to the last saved position (which is first written on load), and if different then it knows the window has moved so it fires off my saveWindowPosition code. It seems to work well, so many thanks for pointing me in the right direction!!

  4. #4
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that was my second thought was a timer event. Glad you got it working. Post the code if you don't mind, that way someone else out there might benefit from it.
    intragenesis, llc professional web & graphic design


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
  •