Results 1 to 3 of 3

Thread: Detecting Mouse Leaving Page

  1. #1
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Detecting Mouse Leaving Page

    I have a mousedown event that turns a variable "resizing" to true, and a mouseup event that sets it to false. I want the "resizing" variable to be set false when the user moves his mouse out of the page into the "menu/bookmarks/scrollbar/statusbar/etc part of the browser" or completely out of the browser.

    I want to do this because if the mouse is released over these areas, my JS won't detect it when the mouse is brought back into the page, and it will still think my resizing script is still taking place.

    NOTE: This script might only work in FF, but that is not an issue for my purposes (at least so far).

    Code:
    http://trinithis.awardspace.com/resize/resize.js

    Demo:
    You should be able to resize the squares like desktop windows.
    http://trinithis.awardspace.com/resize/testWindow.html
    Last edited by Trinithis; 08-09-2007 at 03:24 AM.
    Trinithis

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,925
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    This might work out:

    Code:
    onmouseout=function(e){
    if(!e.relatedTarget)
    stop whatever
    };
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Thanks, it works perfectly.
    Trinithis

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
  •