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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete file when html window closes - vbscript?

Status
Not open for further replies.

FJK77

Programmer
Jul 2, 2002
9
US
Hi,

There is a file I need to delete every time a certain html page is unloaded (either by closing the window or moving onto another html page). I saw that VBScript has a way to delete a file and if I put it in a function like this:

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
function deleteHTML()
dim filesys
set filesys = CreateObject (&quot;Scripting.FileSystemObject&quot;)
demofile.Delete(&quot;D:\myFile.txt&quot;)
end function
</SCRIPT>

then can I call it in the BODY statement using
<<BODY ........ onunload=&quot;deleteHTML()&quot;> ???

Is onunload the right thing to use? If someone has done something like this or knows how to do it, please let me know :)

Thanks,

Frances
 
You did it the right way. Just beware of that :
Code:
dim filesys
set filesys = CreateObject (&quot;Scripting.FileSystemObject&quot;)
demofile
Code:
.Delete(&quot;D:\myFile.txt&quot;)
Water is not bad as soon as it stays out human body ;-)
 
Thankyou for your quick response... I did get it to work (it would help if I remembered to keep the same file name!)
smiletiniest.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top