Page 1 of 1
Is this possible?
Posted: Mon Feb 28, 2005 1:03 pm
by Name-Less
I'm wanting to design a php script that will run when a user closes out of a window. I'm going to use it so if a user closes out of a battle before winning/losing, it will automatically check and delete his account. Is this in any way possible?
Posted: Mon Feb 28, 2005 1:05 pm
by feyd
outside of Javascript, not possible without a "live" connection system.. which again, isn't possible with PHP (directly). Java, Flash, and a few other streaming systems can do it.
Posted: Mon Feb 28, 2005 1:05 pm
by John Cartwright
Moved to Client-Side
Posted: Mon Feb 28, 2005 1:11 pm
by Name-Less
Well, is it possible with a javascript "onClick-style" command to run a php script?
I mean, is there some onFocus, onClick, onMouseOver, etc. type javascript that will run when a window closes? If it is, I would direct it to a php script. . .
Posted: Mon Feb 28, 2005 1:15 pm
by feyd
onunload.
be careful with that though. As that event is called for any page change.
Posted: Mon Feb 28, 2005 1:17 pm
by Name-Less
First, is this including a form submit that reloads to the same page?
Second, do you know if you would be able to have it load up an external php file, in order to run the script?
Posted: Mon Feb 28, 2005 1:19 pm
by feyd
Any page change will call it.
it's apart of the regular Javascript event model.. so anything Javascript can do, it can be done through it.
Posted: Mon Feb 28, 2005 1:22 pm
by Name-Less
Alright, thanks.
Posted: Mon Feb 28, 2005 4:11 pm
by onion2k
Surely a better way of doing this would just be to record the time a battle starts, and if its not ended within a set period assume something has gone wrong. If it happens more than a couple of times, then you inform the user that their account isn't registering the results of battles correctly and ask them to fix it. If it carries on yet further, then you disable their account.
Quite a bit of work there though..
EDIT: Thinking about it, you don't need to do all that. Just record that the user has a battle in progress, and don't let them start another one until that battle has finished, or if they admit defeat in it. So if they close the window before the battle is over the only way they can have another one is to admit they lost.