I have code in place to catch the window close event. At window close time I want to submit a hidden form that I update during the session. The updating is working flawlessly. The call to submit() within onbeforeclose() works on most browsers except, of course, IE running on 2000/XP. Sometimes IE makes the form submission before closing the window and sometimes not. If I add an alert message after the call to the submit() method (see code below), IE always makes the form submission. It is almost as if the form object is sometimes destroyed before it can be submitted.
Has anyone ever run into this problem? Using a modal alert message to pause the window close long enough to submit the form is not an option available to me. Is there a way to verify that the form has been submitted before allowing the window close operation to continue?
code follows:
<script language="JavaScript">
<!--
window.onbeforeunload = unload_handler;
function unload_handler()
{
var frm = document.getElementById("FORM1");
frm.KEY.value = "key value";
frm.DATA.value = "data value";
frm.action = "accessCustomData.jrun?ACTION=storeQuiet";
frm.submit();
}
//-->
</script>
<form id="FORM1" name="FORM1" method="post" style="height:0px;display:none;" target="invisibleFrame">
<input type="hidden" name="KEY" value="">
<input type="hidden" name="DATA" value="">
</form>
Has anyone ever run into this problem? Using a modal alert message to pause the window close long enough to submit the form is not an option available to me. Is there a way to verify that the form has been submitted before allowing the window close operation to continue?
code follows:
<script language="JavaScript">
<!--
window.onbeforeunload = unload_handler;
function unload_handler()
{
var frm = document.getElementById("FORM1");
frm.KEY.value = "key value";
frm.DATA.value = "data value";
frm.action = "accessCustomData.jrun?ACTION=storeQuiet";
frm.submit();
}
//-->
</script>
<form id="FORM1" name="FORM1" method="post" style="height:0px;display:none;" target="invisibleFrame">
<input type="hidden" name="KEY" value="">
<input type="hidden" name="DATA" value="">
</form>