Refresh (reload) a page once using jQuery?

前端 未结 14 1757
眼角桃花
眼角桃花 2020-11-30 22:34

I\'m wondering how to refresh/reload a page (or even specific div) once(!) using jQuery?

Ideally in a way right after the DOM structure is available (c

相关标签:
14条回答
  • 2020-11-30 23:01

    Use this:

        <script type="text/javascript">
            $(document).ready(function(){
    
                // Check if the current URL contains '#'
                if(document.URL.indexOf("#")==-1)
                {
                    // Set the URL to whatever it was plus "#".
                    url = document.URL+"#";
                    location = "#";
    
                    //Reload the page
                     location.reload(true);
                }
            });
        </script>
    

    Due to the if condition, the page will reload only once.

    0 讨论(0)
  • 2020-11-30 23:02

    Try this:

    <input type="button" value="Reload" onClick="history.go(0)">
    
    0 讨论(0)
提交回复
热议问题