473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Detecting onmouseup outside browser window?

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.
Jul 23 '05 #1
20 7848
Mandy Memphis wrote:
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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
"Randy Webb" <hi************@aol.com> wrote in message
news:8Y********************@comcast.com...
Mandy Memphis wrote:
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.


Hi Randy,

Walter Zorn has managed it. See here:

http://www.walterzorn.com/dragdrop/dragdrop_e.htm

I just wish his code wasn't so cryptic!
Jul 23 '05 #3
On Mon, 5 Jul 2004 13:15:03 -0400, Mandy Memphis wrote:
"Randy Webb" <hi************@aol.com> wrote in message
Mandy Memphis wrote:
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.

... Walter Zorn has managed it. See here:

http://www.walterzorn.com/dragdrop/dragdrop_e.htm


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

E.G. If you make your browser window 'little' and
put it in the middle of the screen, you can drag
the mouse out of the window on the right, the image
will keep scrolling (too the right). While the image
keeps scrolling (within the web page), you can move
the mouse pointer around the outside of the window,
when you enter it on the left, the script seems to
recognize *that* and the image which was still scrolling
right now jumps to the left of the screen.

That behaviour supports what Randy was saying,
the script is not aware of the co-ords of the
mouse when it is beyond the window.

It is a security thing AFAIU, you do not want some
script from a web-page able to monitor what you
do beyond the browser, that could allow all sorts
of nasty snooping.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #4
Andrew Thompson wrote:
Walter Zorn has managed it. See here:
http://www.walterzorn.com/dragdrop/dragdrop_e.htm 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 Memphis wrote: 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...

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #5
On Mon, 5 Jul 2004 14:53:12 -0500, Matt Kruse wrote:
Andrew Thompson wrote:
Walter Zorn has managed it. See here:
http://www.walterzorn.com/dragdrop/dragdrop_e.htm

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)


Oops, my bad.. forgot to mention I tested in
Moz 1.3.. (actually I did not even notice till
you mentioned the page, I had both browsers
open at the time..)

Probably some IE security hole.. ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #6
Mandy Memphis wrote:
"Randy Webb" <hi************@aol.com> wrote in message
news:8Y********************@comcast.com...

<--snip-->
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.
http://www.walterzorn.com/dragdrop/dragdrop_e.htm

I just wish his code wasn't so cryptic!


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.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #7
On Mon, 05 Jul 2004 19:27:08 -0400, Randy Webb wrote:
I drug the cat down, let go of the mouse outside the window,


Isn't is safe to let the mouse go inside the
window if the cat is drugged? Maybe not if
it's speed or coke though. ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #8
"Randy Webb" <hi************@aol.com> wrote in message
news:59********************@comcast.com...
Mandy Memphis wrote:
"Randy Webb" <hi************@aol.com> wrote in message
news:8Y********************@comcast.com...


<--snip-->
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.
http://www.walterzorn.com/dragdrop/dragdrop_e.htm

I just wish his code wasn't so cryptic!


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
Jul 23 '05 #9
Randy Webb wrote:
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.

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #10
Mandy Memphis wrote:

<--snip-->

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


No, because it doesn't work.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #11
Matt Kruse wrote:
Randy Webb wrote:
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.


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.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #12
"Randy Webb" <hi************@aol.com> wrote in message
news:7o********************@comcast.com...
Mandy Memphis wrote:

<--snip-->

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


No, because it doesn't work.


Work for me.
Jul 23 '05 #13
On Tue, 6 Jul 2004 21:40:04 -0400, Mandy Memphis wrote:
No, because it doesn't work.


Work for me.


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. )

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #14
Andrew Thompson wrote:
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.

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #15
On Wed, 7 Jul 2004 11:14:37 -0500, Matt Kruse wrote:
..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.


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

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #16
Andrew Thompson wrote:
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. :)

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #17
Matt Kruse wrote:
Andrew Thompson wrote:
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,


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.
Jul 23 '05 #18
"Randy Webb" <hi************@aol.com> wrote in message
news:7o********************@comcast.com...
Matt Kruse wrote:
Randy Webb wrote:
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.


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.


I'm not sure if he has deliberately obfuscated it, but it isn't very clear,
that's for sure. His attitude seems to be "why do something in 10 lines when
you can do it all in one", and "why name something intuitively when you can
use two random letters". Maybe it's because he's German? :) However, it
seems to work well in IE anyway. As for Mandy's problem...

In IE you can capture the document.onmouseover event and return false from
it in order to cancel the default action (which is to stop updatng the mouse
coords beyond the window boundary). The mouse coords can then be read from
the event.clientX and event.clientY properties. Another side effect of doing
this is that the document.onmouseup event will now fire while the mouse is
outside the browser (while the browser is active). Note that setting the
event.cancelBubble property in the document.onmouseover event is independent
of cancelling the default action.

HTH
Jul 23 '05 #19
Matt Kruse wrote:
Andrew Thompson wrote:
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.


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.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #20
Matt Kruse wrote:
Andrew Thompson wrote:
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.


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".

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Frances Del Rio | last post by:
pls, why is this not working? <SCRIPT language=JavaScript type="text/javascript"> var br = '<SCRIPT language=Javascript' br += 'src="js_pop.js" type="text/javascript">' br += '</SCRIPT>' var...
2
by: David Wake | last post by:
I am a complete Javscript newbie trying to produce a user interface similar to Google Maps -- the user should be able to click anywhere on the map and drag it in any direction. The Javascript...
79
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the...
5
by: Dag Sunde | last post by:
Is it possible to detect if the user minimizes the browser-window? I do some polling, and want to stop it while the window in minimized, but not when it only is blurred... TIA... -- Dag.
3
by: mk | last post by:
Hi I'v got the following javascript (part of it) that works with the event onmouseup: // Attach event handlers to all images within container...
1
by: Jason | last post by:
I am creating a Comet/Ajax chatroom system. When people go to the page, it will add them to the list of people in the room via window.onload. When they leave, disconnect, go to another page, or...
9
by: jon | last post by:
Hello, I'm trying to experiment with some javascript to do some custom dragdrop handling. I wish to use the onMouseDown event to trigger the start of my drag, and onMouseup for a potentential...
1
by: Mango | last post by:
I'm trying to print some text in a very specific position on a page, so that it will show through the window of an envelope when folded. This is easy to do, as long as the browser's print margins...
11
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/onmouseup.html In Firefox, if I click in the black box and then release, I get a popup. If I click, drag the cursor, and then release, I don't....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.