The only way I know you can do this would be using the <BODY ONUNLOAD="... [Call your function here]">
That's how most people do it. Essentially since you can't pass values back and forth between CF and JS what you would simply need to do is create a template that creates a session variable or deletes all session variables.
SNIPPETS:
[IN YOUR SOURCE TEMPLATE - THE ONE YOU WANT TO FIRE THE ACTION WHEN YOU CLOSE IT]
<SCRIPT LANGUAGE="Javascript">
closerTemplate = 'http://www.myserver.com/m
function closerCaller(){
myWin=window.open(closerTe
}
</SCRIPT>
[THEN IN THE BODY TAG OF THAT PAGE - OBVIOUSLY IN ADDITION TO WHATEVER YOU HAD IN THERE PREVIOUSLY]
<BODY onunload='closerCaller()'>
Now then, all that's left to do is create the 'myclosertemplate.cfm' page on which you simply need to run your function to perform either your variable writing or your destroy your SESSION structure.
And for future referrence, it is usually better to do something like:
<CFLOOP COLLECTION="#Session#" ITEM="sessionVar">
<CFSET StructDelete(Session, sessionVar)>
</CFLOOP>
If you want to clear the session variables for a particular session. After that you can simply use a ending <CFLOCATION> tag to call a javascript function to close the window for them or if you're really lazy just display a text message that says something like 'Maintenance Completed... Please close this window'
There are hundreds of ways of approaching this issue... if you give more specific details of what you want to achieve exactly and what logic you maintain to determine the appropriate action, I'll be happy to make a sample that you could actually cut and paste into your template, but this ought to get you going in the right direction.
Good luck.
Main Topics
Browse All Topics





by: jyokumPosted on 2004-04-03 at 21:09:22ID: 10750833
what's the error?
)>
might be a copy/paste error, but you're missing an opening < in your cfif statement
<cfset temp=structclear(session)>
<cfif IsDefined("Cookie.CFID") AND IsDefined("Cookie.CFTOKEN"
<cfset cfid1 = Cookie.CFID>
<cfset cftoken1 = Cookie.CFTOKEN>
<cfcookie name="CFID" value="#cfid1#">
<cfcookie name="CFTOKEN" value="#cftoken1#">
</cfif>