Is there a way to detect if the user has pressed the refresh button using jquery or javascript?

前端 未结 5 2031
[愿得一人]
[愿得一人] 2021-01-22 12:48

I want to know if jquery or javascript can detect if the user has pressed the refresh button of their browser? If so can I see an example?

5条回答
  •  清酒与你
    2021-01-22 13:06

    window.onunload event will be fired before the page is going to be refreshed.

    window.onunload = function(){
        alert("unload event detected!");
    }
    

提交回复
热议问题