By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,616 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,616 IT Pros & Developers. It's quick & easy.

Detecting stop button...presumably with JavaScript

P: n/a
Hello. I'm wondering if someone can answer something I'm sure has been
answered a thousand times before. I am apparently just too dumb to
find the answer. :) I've found information about the 'onstop' event,
but it's not behaving as expected. (And it also seems to be a
proprietary attribute) That is, my defined function is not being run
when I click stop. I've 'inserted' it like this:
<body onstop="stopped_clicked()">
And the function just grabs the id of the content div, then changes the
innerHTML. Except that's not what happens. :) Nothing happens.

Oh, about the question. I'm trying to determine if the user clicks the
stop button during a post send, basically. Specifically, if a user is
uploading a file to my server, and they click stop at some point, I
need to be able to tell the server that stop was clicked, so it doesn't
think that's the whole file. I've noticed that an error message is
written to the Apache log, but that seems like a strange way to keep
track of user-interrupted events. (Note: this is Apache/mod_perl
server-side)

I guess what I'm thinking now is that JavaScript detects the stop
(since it is client-side), then sends a message to the server that an
error occurred, or something. Like I said, the onstop event is not
doing what I'm expecting, and Firefox doesn't like it anyway, not to
metion the other browsers out there. So my question is what's the
"idiom" or "standard way" of detecting this sort of situation. I'm
quite certain I'm not the first one to need it. It just seems I'm one
of the ones who has to ask. :)

Thanks for any help,
jab3

Mar 6 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
jab3 wrote on 06 mrt 2006 in comp.lang.javascript:
<body onstop="stopped_clicked()">
And the function just grabs the id of the content div, then changes the
innerHTML. Except that's not what happens. :) Nothing happens.


If you mean by "onstop" that the execution of javascript has stopped,
you should understand that such "onstop" cannot execute javascript.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 6 '06 #2

P: n/a
jab3 wrote:
Oh, about the question. I'm trying to determine if the user clicks the
stop button during a post send, basically. Specifically, if a user is
uploading a file to my server, and they click stop at some point, I
need to be able to tell the server that stop was clicked, so it doesn't
think that's the whole file.


I don't play with perl, so I don't have any idea of what you can do.

Anyway, you *must* solve this problem on the server. Forget about
JavaScript to solve it, using JavaScript in this case is bad and wrong =/
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Mar 6 '06 #3

P: n/a
jab3 wrote:
[...] That is, my defined function is not being run
when I click stop. I've 'inserted' it like this:
<body onstop="stopped_clicked()">
And the function just grabs the id of the content div, then changes the
innerHTML. Except that's not what happens. :) Nothing happens.
The HTML `body' element does not have an `onstop' attribute (how did
you get that idea anyway?). There is an `onstop' event handler for
the `document' object in the Internet Explorer DOM that "fires when
the user clicks the Stop button or leaves the Web page":

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onstop.asp>

However, "There is no public standard that applies to this event." It
is not equally supported in the Gecko DOM, for example. And you cannot
distinguish between the Stop button (or Esc) and "leaving the Web page"
anyway.

When the current browser process is stopped by the user, everything is
supposed to stop, including client-side scripts. What you are trying
to do is like showing an error message with script code in case there
is no script support ;-)
Oh, about the question. I'm trying to determine if the user clicks the
stop button during a post send, basically. [...]


You cannot on the Internet. Observe what happens on your server then
instead, and handle that accordingly.
PointedEars
Mar 6 '06 #4

P: n/a
Jonas Raoni wrote:
jab3 wrote:
Oh, about the question. I'm trying to determine if the user clicks the
stop button during a post send, basically. Specifically, if a user is
uploading a file to my server, and they click stop at some point, I
need to be able to tell the server that stop was clicked, so it doesn't
think that's the whole file.


I don't play with perl, so I don't have any idea of what you can do.

Anyway, you *must* solve this problem on the server. Forget about
JavaScript to solve it, using JavaScript in this case is bad and wrong =/


Yeah, I should've figured as much. I tried matching the Content-Length
header with the actual amount received, but it didn't seem to work.
I'll go back and tinker with it on the server side.

Thanks,
jab3

Mar 6 '06 #5

P: n/a

Thomas 'PointedEars' Lahn wrote:
jab3 wrote:
[...] That is, my defined function is not being run
when I click stop. I've 'inserted' it like this:
<body onstop="stopped_clicked()">
And the function just grabs the id of the content div, then changes the
innerHTML. Except that's not what happens. :) Nothing happens.
The HTML `body' element does not have an `onstop' attribute (how did
you get that idea anyway?). There is an `onstop' event handler for
the `document' object in the Internet Explorer DOM that "fires when
the user clicks the Stop button or leaves the Web page":

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onstop.asp>


Um, yeah, not sure how I got the idea that it was a body attribute.
Somewhere I got onload confused with other stuff or something. :) Hey,
I'm new to JavaScript "ova'here". ;)
When the current browser process is stopped by the user, everything is
supposed to stop, including client-side scripts. What you are trying
to do is like showing an error message with script code in case there
is no script support ;-)


HA. After the replies I've gotten, I've realized the absurdity in my
thinking, or lack there of. (shrug) Oh well.
Oh, about the question. I'm trying to determine if the user clicks the
stop button during a post send, basically. [...]


You cannot on the Internet. Observe what happens on your server then
instead, and handle that accordingly.


Aye. That'll be tonight.

Thanks,
jab3

Mar 6 '06 #6

P: n/a
jab3 wrote:
Jonas Raoni wrote:
jab3 wrote:

Yeah, I should've figured as much. I tried matching the Content-Length
header with the actual amount received, but it didn't seem to work.
I'll go back and tinker with it on the server side.


That's it, you should read the http spec, probably the answer is waiting
for you there... There must be a header saying that the transfer failed
or whatever, you just need to discover hehe, good luck :)
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Mar 6 '06 #7

P: n/a
jab3 wrote:
Jonas Raoni wrote:
Anyway, you *must* solve this problem on the server. Forget about
JavaScript to solve it, using JavaScript in this case is bad and wrong =/

Not quite true. JavaScript can be server-side. What matters that this
problem cannot be solved _client-side_, no matter the language.
Yeah, I should've figured as much. I tried matching the Content-Length
header with the actual amount received, but it didn't seem to work.
I'll go back and tinker with it on the server side.


That is strange because the value of the Content-Length header in the
request (as evaluated server-side) is supposed to be exactly what you
should compare against. Are you confusing request and response here?
PointedEars
Mar 7 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.