Detecting onmouseup outside browser window?

M

Mandy Memphis

If I perform a mousedown within a document, move the mouse outside the
browser window, and then release the mouse button, the document.onmouseup
event does not fire. Is there any way to detect a mouseup event outside the
document?

Also, how can I get the relative coordinates of the cursor while it is
outside the browser?

Thank you.
 
R

Randy Webb

Mandy said:
If I perform a mousedown within a document, move the mouse outside the
browser window, and then release the mouse button, the document.onmouseup
event does not fire. Is there any way to detect a mouseup event outside the
document?
No.

Also, how can I get the relative coordinates of the cursor while it is
outside the browser?

You can't.
 
M

Matt Kruse

Andrew said:
You assertion does not seem to be borne out
by the way the code acts.

On the contrary, it works for me.
If I resize my browser (IE6) to the middle of the screen, I can drag
something off to the left. While my cursor is outside of the browser window
completely, I can still move the image around (and my cursor stays as a
'move' graphic). When I let go, outside of the browser window, it stops
dragging. This was the behavior that the OP was asking for, I believe.

Mandy said:
I just wish his code wasn't so cryptic!

Me too, he has some good functions in there. But trying to reuse or alter
any of them is more work than it's worth...
 
R

Randy Webb

Hi Randy,

Walter Zorn has managed it. See here:

No, he has attempted to manage it. It fails, utterly, in Mozilla.
I drug the cat down, let go of the mouse outside the window, and even
while I am typing this, it is still attempting to scroll the cat down
even more.

When I see code like this:

href="javascript:void(0)"

I tend to stop reading anymore, as the author code such as that isn't
very aware of reality on the web.
 
M

Mandy Memphis

Randy Webb said:
No, he has attempted to manage it. It fails, utterly, in Mozilla.
I drug the cat down, let go of the mouse outside the window, and even
while I am typing this, it is still attempting to scroll the cat down
even more.


When I see code like this:

href="javascript:void(0)"

I tend to stop reading anymore, as the author code such as that isn't
very aware of reality on the web.

He was aware enough to get something to work that you said couldn't be done!
;-P
 
M

Matt Kruse

Randy said:
When I see code like this:
href="javascript:void(0)"
I tend to stop reading anymore, as the author code such as that isn't
very aware of reality on the web.

I don't think that's a fair statement.
Obviously, Mr. Zorn is not a newbie script kiddie, and to be so judgemental
of his abilities based on a snippet of code is a bit unwarranted, IMO.
 
R

Randy Webb

Matt said:
I don't think that's a fair statement.
Obviously, Mr. Zorn is not a newbie script kiddie, and to be so judgemental
of his abilities based on a snippet of code is a bit unwarranted, IMO.

No, he is not a newbie script kiddie, but I still tend to discount code
written that has snippets of that in it. I also tend to discount code
that has attempted obfuscation in it, and thats based on his .js file.
 
M

Matt Kruse

Andrew said:
The natural assumption on this group is that you
are developing for the web unless otherwise stated.
On the web, it does not work. ( Note that you
have already had a 50% failure rate in the
4 tests conducted. )

It would be more correct to say that on the web, it does not work with all
browsers, but most likely does work for the majority of users. Also, it
appears to degrade gracefully (not causing any problems in browsers where it
doesn't work) which is exactly what we'd want.

So, in summary, it appears to be a fantastic solution, IMO.
 
M

Matt Kruse

Andrew said:
Doesn't have the same ring to it as..
"50% failure rate in the 4 tests conducted."
..which is an accurate statement.

a) Flawed statistics are meaningless. "100% success rate in the browsers
used by 94% of site visitors" is another statistic which might be accurate.
b) Every single javascript every written will fail in at least one situation
c) It doesn't really matter, since the solution does exist, works nicely in
a subset of browsers, and degrades gracefully - everything js code should
do. :)
 
R

Richard Cornford

Matt said:
It would be more correct to say that on the web, it does not work
with all browsers,

Surly it does not work with all browser whether on the web or not. The
web is just the place where it can expect to encounter all browsers (or
at least stand a chance of encountering them).
but most likely does work for the majority of
users. Also, it appears to degrade gracefully (not causing any
problems in browsers where it doesn't work) which is exactly what
we'd want.

Well, we have a thread about monitoring the mouseup event outside of the
window/document, and that definitely does not work on many browsers, and
then only under some circumstances (only when dragging in IE, for
example).

The code under discussion does make a reasonable attempt at clean
degradation, but it is a long way from being cross-browser, reliable or
good. And some of the implementation details make me think that it could
be extremely problematic on Safari or Konqueror (to name but two) with
the script partly running and then erroring mid process due to the use
of object-inference browser detection instead of the feature detection
that it almost achieves. That type of uncontrolled failure mid flow is
likely to undo the good work put into clean degradation by leaving the
page in an intermediate state that may not be nearly as viable as the
original HTML.
So, in summary, it appears to be a fantastic solution, IMO.

If you understood what the script was doing you would not be attaching
"fantastic" to it as a label. It is an above average script with some
serious design flaws and as a result should only be expected to exhibit
planned behaviour on the limited test-set of browsers stated in its
documentation.

It is actually a bit disappointing as a product of its author as his
vector graphics library is a really good implementation of efficient
line and arc drawing algorithms in javascript. Which contrasts horribly
with a script that even features an eval-ed dot notation property
accessor.

Richard.
 
G

Grant Wagner

Matt said:
a) Flawed statistics are meaningless. "100% success rate in the browsers
used by 94% of site visitors" is another statistic which might be accurate.

His statistics aren't flawed. His choice of tests or his testing methodology
might be, causing him to get the failure rate he desires, but the statistics
themselves are (presumably) accurate. Of the four tests he chose to conduct, the
page failed half the time. The trick lies in finding the right four tests to
use.
b) Every single javascript every written will fail in at least one situation

This depends on how you define "failure". If the code never executes, then can
it be considered to have "failed".

I doubt <script type="text/javascript">var n = 0;</script> has ever failed in at
least one situation, unless you define failure to include not executing at all
(in the case of a user agent which does not support JavaScript, or JavaScript is
not enabled).
c) It doesn't really matter, since the solution does exist, works nicely in
a subset of browsers, and degrades gracefully - everything js code should
do. :)

I right-clicked the links in question and chose "Open Link in New Active Tab". I
got a blank document. Not too graceful a degradation.

I'm not particularly sure what would be so terribly wrong with:

<a href="noJS.html" onclick="...;return false;">...</a>

with noJS.html:

<html>
<head>
<title>JavaScript not enabled or link not single clicked</title>
</head>
<body>
<p>You need JavaScript enabled to enjoy what this link does. Be sure to single
click the link with your primary mouse button to activate it.</p>
</body>
</html>

Simple to implement, does not require much more work then <a
href="javascript:void(0);" ...> and would avoid silly arguments on usenet.
 
R

Randy Webb

Matt said:
It would be more correct to say that on the web, it does not work with all
browsers, but most likely does work for the majority of users. Also, it
appears to degrade gracefully (not causing any problems in browsers where it
doesn't work) which is exactly what we'd want.

When I tested it in Mozilla, it half worked. It let me drag it down, and
then when I released the mouse (expecting it to stop scrolling), it
continued to try to move the cat downwards. Even when I went to the top
of the document and clicked on it, it continued to try to scroll the cat
downwards. Not what I would consider "degrading gracefully".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top