JavaScript to reload the page as GET request

前端 未结 3 1292
猫巷女王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条回答
  • 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;
    }
    
    0 讨论(0)
  • 2021-01-04 02:18

    Try the following:

    location.replace(location.href)
    
    0 讨论(0)
  • 2021-01-04 02:21

    You can try this

    location=location.href
    
    0 讨论(0)
提交回复
热议问题