火狐下刷新的问题

我想在页面刷新之前,然后页面的里一个表单先提交下。
[code="java"]window.onbeforeunload=function (event){

event = (event)?event:window.event;

if (event.clientX < 0 && event.clientY < 0  ||  event.altKey) {
    exitsystems();
}
 else {
    window.location.href = "<%=request.getContextPath() %>/page/user.do?method=closed"; 
    alert("1");
}

} [/code]
代码如上,else里面有个alert("1")看起来是多余的,如果在火狐上,不加上的话,就不会执行[code="java"]window.location.href = "<%=request.getContextPath() %>/page/user.do?method=closed"; [/code]
请教各位如何解决这个问题,alert("")肯定是不需要的,不然每次刷新页面都会跳个对话框出来。

可能的问题是window.location.href赋值后,网页的执行是异步的,所以在关闭网页之前,来不及提交。alert是阻塞事件的,所以你能看到。

改造的流程应该是,先中断当前事件执行,提交,然后再继续执行改事件。

首先确定是不是js有错误,另外在window.location.href后面加一句window.event.returnValue=false;试试