Identifying Between Refresh And Close Browser Actions

前端 未结 13 1207
孤街浪徒
孤街浪徒 2020-11-22 15:29

When we refresh the page (F5, or icon in browser), it will first trigger ONUNLOAD event. When we close the browser (X on right top icon),It will trigger ONUNLOAD event. Now

13条回答
  •  悲哀的现实
    2020-11-22 16:02

    My earlier solution worked for me in IE. window.event would be undefined for browsers other than IE as 'event' is globally defined in IE unlike in other browsers. You would need to supply event as a parameter in case of other browsers. Also that clientX is not defined for firefox, we should use pageX.

    Try something like this....should work for IE and firefox this...

    
    
    
    
    
    

提交回复
热议问题