How to check page is reloading or refreshing using jquery or javascript?

前端 未结 4 1028
说谎
说谎 2020-12-06 00:43

I have to do some kind of operation on the page refresh or reload. that is when I hit next page or Filter or refresh on the grid. I need to show some confirmation box over t

4条回答
  •  失恋的感觉
    2020-12-06 01:38

    You can create a hidden field and set its value on first page load. When the page is loaded again, you can check the hidden field. If it's empty then the page is loaded for the first time, else it's refreshed. Some thing like this:

    HTML

    
    
        
    
    
    

    JS

    function CheckPageLoad() {
        if (document.getElementById("visit").value == "") {
            // This is a fresh page load
            document.getElementById("visit").value = "1";
        }
        else {
            // This is a page refresh
        }
    }​
    

提交回复
热议问题