Jump to content

Run script on page leave


TitusRevised

Recommended Posts

this would be a client side trigger so you would have to use JavaScript.

i would not use this approach though. many things can go wrong...the user could close the browser or kill the browser process on his OS, the browser could crash, the ISP could drop his connection. too many uncertainties in my...but who knows, maybe someone knows something i don't and this is possible but as far as i know, i don't think this is a good solution.
Link to comment
Share on other sites

[quote author=Koobi link=topic=99548.msg392058#msg392058 date=1152121255]
this would be a client side trigger so you would have to use JavaScript.

i would not use this approach though. many things can go wrong...the user could close the browser or kill the browser process on his OS, the browser could crash, the ISP could drop his connection. too many uncertainties in my...but who knows, maybe someone knows something i don't and this is possible but as far as i know, i don't think this is a good solution.
[/quote]
Well, the the page information wil be saved in a session so if they close browser then no need to execute a script. But if they navigate away from that single page, then I need a script to run first then send them to where they want to go. If it has to be done in JavaScript, can anyone direct me to help?
Link to comment
Share on other sites

oh ok then you can do something here. sorry i misunderstood your first post.

in this case i think the safest thing to do would be to have an intermediate page that redirects the user to their requested page.

so your user wants to go from one.php to two.php and the moment he leaves one.php, you want the script to execute.

the link he clicks would take him to intermediate.php and this script's job is to redirect the user to the requested page based on certain conditions.
these conditions could be the execution of your query for example.
so you would have a session variable that tracks URL's and the moment this changes, you would execute this query of yours and then redirect him from this page (i.e. intermediate.php) to two.php


hope that made sense.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.