Preventing Firefox reload confirmation

前端 未结 6 2014
一生所求
一生所求 2021-02-05 10:00

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.

相关标签:
6条回答
  • 2021-02-05 10:34

    The way to avoid that prompt is to not create a situation where a user is trying to reload a POST result page.

    0 讨论(0)
  • 2021-02-05 10:41

    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

    0 讨论(0)
  • 2021-02-05 10:42

    Using

    window.location=window.location;
    

    Instead of

    location.reload();
    

    work for me.

    0 讨论(0)
  • 2021-02-05 10:42

    Try this.

    setTimeout (function () {
        window.location.reload();
    },0);
    
    0 讨论(0)
  • 2021-02-05 10:46

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

    0 讨论(0)
  • 2021-02-05 10:52
    window.opener.location.href = window.opener.location;
    

    I've found the decision here

    (Tested on Firefox 32 and Chrome 38 successfully.)

    0 讨论(0)
提交回复
热议问题