Link to home
Start Free TrialLog in
Avatar of Tpaul_10
Tpaul_10Flag for United States of America

asked on

Executing a CF page when the browser is closed or navigates away from a CF page.

Experts,

I need to excute a CF page or file when the user closes the browser or navigates away from a specific CF page.

For example, if the users are closing the browser when they are on finalPage.cfm and I need to excute verifyDetails.cfm page. I also need to get an attribute from finalPage.cfm to verifyDetails.cfm to check my transaction or run verifyDetails.cfm page.

Are there any CF fucntions to do this and is this possible? If so, please let me know how I can do this?

Thanks on Advance.
Avatar of gdemaria
gdemaria
Flag of United States of America image


Nothing can be done when the browser is closed or someone navigates away from your page.

However, you can use onSessionEnd function in your application.cfc file to run some CF code when the session expires.  The session will expire X minutes (usually 20) after the last activity by the user.

SOLUTION
Avatar of Philippe Damerval
Philippe Damerval
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tpaul_10

ASKER

How about something like this.

<script language="JavaScript" event="onbeforeunload()" for="window">
<cfinclude template="act_Cancel.cfm">
</script>

This is working all the time(i mean whenever I move away from this page), but I need to get it worked
only when the window closed.

I need to find out how to use window.close function.

Any suggestions?
Here's a link to a page where they seem to do this. It should apply t you despite the forum being .Net - let me know.
http://forums.asp.net/p/1204326/2226025.aspx

On before load does execute on every page, it's not applicable here.

It seems that forum is being driven by the click of a form button or link, not clicking the browser close button.

I have seen this question again and again on EE, never seen an answer.  I think you need to rethink it.  If you have clean-up to do, consider onSessionEnd()

Thanks for the reply guys and I am looking in to all these options

gdemaria: Can you please give me an example how to use onSessionEnd()?

Thanks


ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Unfortunately, I am still on CF 7 as well as not using CFC at all since it is a old website which was developed USING CF 5.0.


 Application.cfc is supported by Coldfusion 7

 What is it you want to do when the session expires?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the suggestion experts and i have changed the architecture to work differently.