Is this possible?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Name-Less
Forum Newbie
Posts: 7
Joined: Mon Nov 15, 2004 8:26 am
Location: Missouri
Contact:

Is this possible?

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Moved to Client-Side
Name-Less
Forum Newbie
Posts: 7
Joined: Mon Nov 15, 2004 8:26 am
Location: Missouri
Contact:

Post 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. . .
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

onunload.

be careful with that though. As that event is called for any page change.
Name-Less
Forum Newbie
Posts: 7
Joined: Mon Nov 15, 2004 8:26 am
Location: Missouri
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Name-Less
Forum Newbie
Posts: 7
Joined: Mon Nov 15, 2004 8:26 am
Location: Missouri
Contact:

Post by Name-Less »

Alright, thanks.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
Post Reply