Delete Server File When Exiting from Web Page
You can't access server files using Javascript because of security reasons. However, you can make a postback in the onbeforeunload event and on the server-side event (which handles this postback) you can delete the server file(s) to be deleted.
Using a python cgi script and I have a form with both a Submit and Cancel button.  

When a user tries to leave the web page by clicking Cancel, closing the window or hitting the back button, I want to delete a file that exists on the server.  The file name is dependent on the values in the form.
When the user clicks the Submit button, no file will be deleted.  The form action is to take the user to another python cgi script.
I can catch the user leaving the page with  javascript onbeforeunload event, but I can't delete the files in javascript.  How do I delete the files?