如何在刷新页面时调用注销页面?

/* The below code is used to make alert before reload a page */ 
 window.onbeforeunload = function() {
        return "";
}
/* The above code is used to make alert before reload a page */ 

/* i) The above code added to confirm user whether they need to refresh or not. (finished ) ii) If yes i want to call logout page (not yet finished - need help) */

Please try following code.

<script type="text/javascript">
   window.onload = function() {

    if (confirm('Are you sure ?')) {
       // Call log out URL instead of Google
       window.location = "http://www.google.com";
    } else {
       // Do nothing!
       return false;
    }

};
</script>

If user has select ok then He will be redirected to the Google.

Please let me know if your require further information.

Call location.href = 'yourlogoutpage'. Based on your condition it will trigger the location .

You have to follow below snap code, I hope it will be helpful to you.

 window.onbeforeunload = function() {
   $.ajax({
       url: "your_logout_url", // which destroy user session
       type: 'GET',
       aync: false, // it is very usefull on serveside for waiting server response
       success: function(data){
           document.location.href='your_login_page_link'
       }
   });
}

Use event.currentTarget.performance.navigation.type to determine the type of navigation.

function CallbackFunction(event) {
    if(window.event) {
        if(window.event.clientX > 40 && window.event.clientY > 0) { 
            alert("refresh button is clicked");    
        }

    } else {
        if(event.currentTarget.performance.navigation.type == 1) {
            alert("refresh button is clicked");
        }             
    }
}