Detecting stop button...presumably with JavaScript

J

jab3

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
 
E

Evertjan.

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

Jonas Raoni

jab3 said:
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 =/
 
T

Thomas 'PointedEars' Lahn

jab3 said:
[...] 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
 
J

jab3

Jonas said:
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
 
J

jab3

Thomas said:
jab3 said:
[...] 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
 
J

Jonas Raoni

jab3 said:
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 :)
 
T

Thomas 'PointedEars' Lahn

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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top