Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    38

    Tracking mouse events, IE

    I'm experimenting with some DHTML and javascript that involves tracking mouse movements. One of the things I decided to write for learning and testing purposes was a script to drag and resize an object.

    Everything works, as this is a pretty simple script. The only thing that I would like to fix is that IE seems to lose mouse events once the mouse is moved outside of the browser window - Firefox does not.

    I've provided the sample I've been working with. The code is not very good, but it's just a mockup. To see the behavior I'm talking about, click and hold on the bar that says "Click to resize." Before you release the mouse button, drag the cursor outside of the browser window, and then release. When you move the cursor back into the window, IE still thinks that the mouse button is pressed. See what I'm talking about?

    note: The box will only change size vertically, and won't go smaller than a certain height.

    I'm using attachEvent(); to assign event listeners to objects for IE, and addEventListener() for Firefox. Haven't tested any other browsers yet..

    I've seen this done successfully, but I can't figure out where they're managing to handle this in their code. Any suggestions or help would be greatly appreciated!

    http://ideafarm.toastd.com/resize.html

  2. #2
    Join Date
    May 2001
    Location
    Prince Edward Island
    Posts
    964
    IE 6 can move outside the window -- and back in to continue moving --
    [url]I got nothing/url]

    For clarity's sake, don't use "<ip address of hostname>" use the ACTUAL 32-bit numeric IP address of the machine.

  3. #3
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    876
    Can you detachEvent if the cursor leaves the browser?

  4. #4
    Join Date
    Jul 2004
    Posts
    38
    Originally posted by MikeM
    IE 6 can move outside the window -- and back in to continue moving --
    yes, it sure can. but if you follow my instructions, you'll see what the problem is.
    [list=1][*]Click and hold on the "Click to resize" bar[*]Drag the cursor outside of the browser window[*]Release the mouse button[*]Move the cursor back into the browser window[*]The mouse button is no longer pressed, and yet IE thinks it is.[/list=1]
    Originally posted by -T{H}R-
    Can you detachEvent if the cursor leaves the browser?
    i'll have to investigate whether or not IE can detect the mouse leaving the browser window specifically. i have been looking at this script, which works almost exactly as i want:

    http://webfx.eae.net/dhtml/slider/slider.html
    this is the javascript file:
    http://webfx.eae.net/dhtml/slider/js/slider.js

    I can't find any special code for the mouse exiting the bounds of the browser window at all. The mouse events are handled with the same attachEvent() and detachEvent() for IE, and the mouse movement function has no checks for window boundaries. Yet this script seems to work....

  5. #5
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    876
    I think it's just symptomatic of all the problems people have with IE - it's very poorly coded/designed.

Posting Permissions

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