Reload browser window after POST without prompting user to resend POST data

后端 未结 14 2052
盖世英雄少女心
盖世英雄少女心 2020-11-29 05:47

When a user visits my website there is a \"Login\" link on every page. Clicking this uses some JavaScript to show an overlay window where the user is prompted for their cred

14条回答
  •  北海茫月
    2020-11-29 06:11

    If you have hashes '#' in your URL, all the solutions here do not work. This is the only solution that worked for me.

    var hrefa = window.location.href.split("#")[1];
    var hrefb = window.location.href.split("#")[2];
    window.location.href  = window.location.pathname +  window.location.search + '&x=x#' + hrefa + '#' + hrefb;
    

    The URL has to be different for it to reload if you have a hash. The &x=x does that here. Just substitute this for something you can ignore. THis is abit of a hack, unable to find a better solution..

    Tested in Firefox.

提交回复
热议问题