Refreshing page on click of a button

后端 未结 6 1176
无人及你
无人及你 2021-02-02 09:33

I would like to refresh the current page when a button is clicked.

Using JavaScript, I have the following:

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

    I'd suggest <a href='page1.jsp'>Refresh</a>.

    0 讨论(0)
  • 2021-02-02 10:20

    There are several ways to reload the current page using a button or other trigger. The examples below use a button click to reload the page but you can use a text hyperlink or any trigger you like.

    <input type="button" value="Reload Page" onClick="window.location.reload()">
    
    <input type="button" value="Reload Page" onClick="history.go(0)">
    
    <input type="button" value="Reload Page" onClick="window.location.href=window.location.href">
    
    0 讨论(0)
  • 2021-02-02 10:22

    Works for every browser.

    <button type="button" onClick="Refresh()">Close</button>
    
    <script>
        function Refresh() {
            window.parent.location = window.parent.location.href;
        }
    </script>
    
    0 讨论(0)
  • 2021-02-02 10:22
    <button onclick=location=URL>Refresh</button>
    

    Small hack.

    0 讨论(0)
  • 2021-02-02 10:24
    <button type="button" onClick="refreshPage()">Close</button>
    
    <script>
    function refreshPage(){
        window.location.reload();
    } 
    </script>
    

    or

    <button type="button" onClick="window.location.reload();">Close</button>
    
    0 讨论(0)
  • 2021-02-02 10:36

    This question actually is not JSP related, it is HTTP related. you can just do:

    window.location = window.location;

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