Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing Firefox reload confirmation

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?

like image 289
Emmi Avatar asked Sep 27 '12 13:09

Emmi


People also ask

How do I stop Firefox from asking to download?

In Firefox 97 and 98+ there have been changes to the download panel. You can set this pref to false on the about:config page to prevent opening the download panel on each download. You can open the about:config page via the location/address bar. You can accept the warning and click "I accept the risk!" to continue.


5 Answers

Using

window.location=window.location;

Instead of

location.reload();

work for me.

like image 118
Ricardo Huertas Avatar answered Sep 25 '22 06:09

Ricardo Huertas


I solved this, and sent data as only GET instead of POST,

It my not suit all needs but it works....

I was also using location.reload();

like image 35
Mikeys4u Avatar answered Sep 26 '22 06:09

Mikeys4u


The behavior is correct. According to w3schools reload has a parameter forceGet that is default false, and as a result if you have a POST submit, the the browser will try to resend that POST data, and as such, it needs your confirmation. Firefox does this right, and google chrome behaves like it has a default of true for forceGet

http://www.w3schools.com/jsref/met_loc_reload.asp

while window.location=window.location or window.location=window.location.href (or any other variation of this) works most of the time, when you are using an anchor url like http://www.google.com#test will not be refreshed with this method. The browser will do the exact same thing as it will do when you are already on google.com and you change the url by adding #test. The browser will just try to locate the anchor tag in the page that has the name test, and scroll down to it, without refreshing your browser.

The solution that works in this case as well as any other case I encountered would be window.location.reload(true);

Hope this helps,

Alexandru Cosoi

like image 41
Alexandru Cosoi Avatar answered Sep 24 '22 06:09

Alexandru Cosoi


With Firefox 82 (mac) I have found (big chunk of luck) the right parameter to change:

set dom.confirm_repost.testing.always_accept to true

and the confirmation request window will disapear.

like image 25
newbie Avatar answered Sep 24 '22 06:09

newbie


window.opener.location.href = window.opener.location;

I've found the decision here

(Tested on Firefox 32 and Chrome 38 successfully.)

like image 1
Seva Bityukov Avatar answered Sep 24 '22 06:09

Seva Bityukov