All, I have javascript which registers a function for onbeforeunload. In this function, I programmatically submit the form on the page in an attempt to capture and persist any changes made by a user prior to navigating away from the form. The logic you see below mainly consists on deciding whether or not the action is required (getting the value of IsFormSubmit etc.

I have put a breakpoint on the line where form.submit() is actually called. I can verify that the form itself exists, and that the changes I have made to it are present prior to the line of code executing. I see no postback to the server upon call to submit().

What am I doing wrong? Does Chrome support programmatically calling submit() from a function in onbeforeunload? Is this a bug?

The same code below works in IE9, IE8, IE7, Firefox 3.6, Firefox 4.0 but does not work in any version of Chrome or Safari I have tried.

window.onbeforeunload = function() {
var isFormSubmit = Ext.get('IsFormSubmit').value;
if (!TaskExecute._suppressNavigatePostback
&& !TaskExecute._taskCleared
&& (TaskExecute._isReadOnly != "True")
&& (typeof isFormSubmit == 'undefined' || isFormSubmit == null)) {

document.forms['aspnetForm'].submit();

// This code is necessary to slow down the browser momentarily
// to allow the form to submit back to the server before moving
// away from the page, which would cause the submit to not occur.
// This delay is not deterministic, but appears to be sufficient.
var start = new Date().getTime();
while (new Date().getTime() < start + 1000);
}

TaskExecute._suppressNavigatePostback = false;
}