Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script delay or action when close window

Status
Not open for further replies.

JeroenDortmans

Technical User
Aug 7, 2001
56
NL
Hi,

How is it possible to delete a file on the server when a window closes or delete the file after waiting a few seconds?
I now the delete part of the script.
 
As http is a stateless protocol,
You never know when the window was closesd.Because server will always identify each request as unique request and if you are using session variables,it will recognise the closing of browser after 20 default minutes(It could be more) because there is not going to be any request for that Browser ID(A small per session cookie does it)

Well you can never mingle client side activities like losing of browser with server side activity like deleting files using FSO-File System Object.You have to justify the event when you want to delete files.

Well there is a way to trap script timeout through MTS.
So using MTS you can dfine timelimit(Default it offers 60 minutes),you can search google or microsoft.com for the script.
And if it is timing out,you can do some action like deleting of files using FSO.
In the second para maybe I am out of track but because i have not understood the second requirement.
Rushi Shroff Rushi@emqube.com
"Life is beautiful."
 
I understand,

I think I better can delete the file after a few seconds so the user has time to execute it. How can I build in this delay?
 
you said..

I better can delete the file after few seconds so the user has time to execute it..

I dont understand.. Rushi Shroff Rushi@emqube.com
"Life is beautiful."
 
I have an ASP script which creates a file on the server. This script will create a new file name every time the page is opened. After creating the file, I execute it. After a few seconds the window will close. Just before closing the window I want the file to be deleted. I hope this explains enough.
 
aS I HAVE UNDERSTOOD,
What you can do is that you must be closing the browser through te javascript timer code.
What you do is whatever seconds you are setting in javascript timer,ceate some session variable on the server which has little bit less duration than the javascript timer.

Now you can add session_OnEnd event in your global.asa
Remember whoes on page code ??
As you are assuming session ends just before window closes
(or even after that),put the code to delete the file in Global.asa using FSO.

So when session will end Session_OnEnd will fire and will ultimately delete the particular file from the hard disk ..

This is the just the setting i am showing you..
You have to find out how accurately you will do it !
Plan it and do it. Rushi Shroff Rushi@emqube.com
"Life is beautiful."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top