Handle refresh page event with javascript

后端 未结 2 1010
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 01:15

Is it possible to use javascript to handle the event of refreshing page? What i want is get notice if user do one of these behaviours:

  • refresh page by pressing
2条回答
  •  情深已故
    2020-12-03 02:02

    You don't want the refresh, you want the onbeforeunload event.

    http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx

    Sample code from article

    
    
    
    
    
      Click here to navigate to 
          www.microsoft.com
    
    
    

提交回复
热议问题