JavaScript to reload the page as GET request

前端 未结 3 1314
猫巷女王i
猫巷女王i 2021-01-04 01:48

I have a seemingly simple question, but can\'t find the answer. I have a webpage, which may have resulted from a POST request and may have an anchor (#) in the URL. I want t

3条回答
  •  梦毁少年i
    2021-01-04 02:12

    The best I've come up with so far is:

    function reloadAsGet()
    {
        var loc = window.location;
        window.location = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
    }
    

提交回复
热议问题