Preventing Firefox reload confirmation

Emmi picture Emmi · Sep 27, 2012 · Viewed 30.4k times · Source

I'm displaying certain records in an editable table. The user when attempts to reload the table while editing a record a pop up comes warning the record about the unsaved data.

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();
        }
    }
}

When he clicks OK to reload the page, Firefox prompts as

To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.

And when opening the same page in Chrome, no such prompt appears.

I tried to avoid this by setting window.onbeforeunload = null;, but still the prompt window appears there.

Also I tried by changing Firefox configuration:

browser.sessionstore.postdata

Changed 0 to 1 as suggested in Mozilla support page.

But nothing worked.. How do I prevent the prompt?

Answer

Ricardo Huertas picture Ricardo Huertas · Aug 19, 2013

Using

window.location=window.location;

Instead of

location.reload();

work for me.