chrome 的onbeforeunload事件没有触发

onbeforeunload event is not working when user not click inside the body of page

 

0down votefavorite
 

I want call one function when user open any page and without click on that page, he just close the page.

I have tried this to put one button and click on that button using coding after page loading is complete , but it is not working.

I am follow this link. W3School

In this link , when you not click in result portion and reload page then it will not display alert , but when you click result portion and reload page then it will displaying a alert.

 

 

 

This is because the onbeforeunload is attached to the