####perl/cgi####
@checked = param('checkbox');
($uid, $pass) = sieve_util_remove_filter($relay, $relay_dir, $filename, $home_dir, @checked);
###html####
print start_html(-title=>"Sieve Filter Administration",
-script=>{-language=>'javascript',
-src=>'load.js'},
-onbeforeunload=>"closeIt()",
-background=> "gray.jpg"),
####.js######
function closeIt()
{
event.returnValue ="_______________________________________________________ \n\n"+
"Leaving without saving will cause loss of any new or modified data.\n" +
"_______________________________________________________ \n\n"
}
It renders "OK" and "Cancel" buttons with your message that return 'true' or 'false' values.
Hope I'm reading your problem correctly.
T
...to run the cgi...
function closeIt(){
var msg="your_message";
if (confirm(msg) {
location.replace(path_to_cgi)
} else {
location.replace(path_to_elsewhere)
}
}
-or-
function closeIt(){
var msg=window.confirm("your_message");
if (msg==true){
window.location="path_to_cgi";
}
}
...in this second case a click on Cancel leaves them on the original page, OK runs the cgi.
Are we getting close?
T
As far as the user just closing the browser: the dialog box still gets poped up before it allows the browser to close.
And if they have disabled JavaScript? (and don't say "they won't be able to reach the page without having JS enabled"... since they can disable it after loading the page)
Flock the file and do whatever you need to do, but release the flock before loading the page.
'cause, what happens if the computer crashes, or the user does Ctrl-Alt-Del to get out of the page...
The flock must be released before the page is loaded, or, not flocked at all until the user navigates away.