onbeforeunload support detection

前端 未结 10 1175
慢半拍i
慢半拍i 2020-11-28 11:21

I\'d like to check if the current browser supports the onbeforeunload event. The common javascript way to do this does not seem to work:

if (window.onbeforeu         


        
10条回答
  •  星月不相逢
    2020-11-28 11:49

    Different approach, get the typeof

    if(typeof window.onbeforeunload == 'function')
    
    {
    alert("hello functionality!");
    }
    

提交回复
热议问题