galvin Posted May 21, 2009 Share Posted May 21, 2009 Just curious, is there any type of PHP function that does something like... if the current page is left (i.e. clicked away from) { //do this stuff } In other words, if a user goes to thispage.php, they could then click dozens of other links to go to another page on the website. Rather than put code at the top of ALL of those other sites to unset variables that were set on thispage.php, I was hoping there was some code that could just be put on thispage.php that would unset certain variables when the user LEAVES thispage.php. If that makes any sense, is there anthing like that? Link to comment https://forums.phpfreaks.com/topic/159017-solved-running-code-when-a-user-leaves-a-certain-page/ Share on other sites More sharing options...
michaellunsford Posted May 21, 2009 Share Posted May 21, 2009 nope, but javascript does: http://www.w3schools.com/jsref/jsref_onunload.asp Link to comment https://forums.phpfreaks.com/topic/159017-solved-running-code-when-a-user-leaves-a-certain-page/#findComment-838625 Share on other sites More sharing options...
shlumph Posted May 21, 2009 Share Posted May 21, 2009 Yeah, it'd have to be a javascript function to grab when the window was closed. You could AJAX it to run a PHP function, though. Link to comment https://forums.phpfreaks.com/topic/159017-solved-running-code-when-a-user-leaves-a-certain-page/#findComment-838638 Share on other sites More sharing options...
galvin Posted May 22, 2009 Author Share Posted May 22, 2009 great idea, shlumph. that should do what I need. thanks! Link to comment https://forums.phpfreaks.com/topic/159017-solved-running-code-when-a-user-leaves-a-certain-page/#findComment-840290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.