防止Firefox重新加载确认

Emm*_*mmi 16 javascript firefox google-chrome onbeforeunload reload

我在可编辑的表格中显示某些记录.当用户在编辑弹出的记录时尝试重新加载表时,会警告有关未保存数据的记录.

function cancelProcess()
{
    if(noEditedRecords !=0)//number of edited records in the table
    {
        var processConfirmation = confirm("You've Edited "+ noEditedRecords +" Records. Are You sure to undo the Changes made?");

        if (processConfirmation ==true){
            window.onbeforeunload = null;
            window.location.reload();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当他单击"确定"重新加载页面时,Firefox会提示为

要显示此页面,Firefox必须发送将重复之前执行的任何操作(例如搜索或订单确认)的信息.

在Chrome中打开同一页面时,不会出现此类提示.

我试图通过设置避免这种情况window.onbeforeunload = null;,但仍然会出现提示窗口.

我也试过改变Firefox配置:

browser.sessionstore.postdata

根据Mozilla支持页面中的建议将0更改为1.

但没有任何效果..如何阻止提示?

Ric*_*tas 36

运用

window.location=window.location;
Run Code Online (Sandbox Code Playgroud)

代替

location.reload();
Run Code Online (Sandbox Code Playgroud)

为我工作.


Bor*_*sky 0

避免出现该提示的方法是不要造成用户尝试重新加载 POST 结果页面的情况。