faqts : Computers : Programming : Languages : PHP : Not Quite PHP : Javascript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

35 of 57 people (61%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Can I execute some php code in an unLoad statement. I've tried but I'm not JavaScript handy. :) I'm looking for a unload("<? commands ?>")

Jul 29th, 2001 22:06
Onno Benschop, John Marc, John,


No.
The unload command is javascript. Therefor all commands between the 
quotes are also javascript.
Let me elaborate:
An unload event is issued by the browser when a page is about to close. 
The language of this event is javascript.
So, no you cannot have PHP code execute on an unload.
You could make a PHP page, and have the unload command call that php 
page by reference.
You could have PHP generate the actual script for the javascript 
unload, but you cannot have PHP directly execute as the result of a 
browser unload.