window.onbeforeload() event is not working ?

window.onbeforeload() event is not working ?

Hello,

I am able to open the event dialog only while inspecting it (F12 key) and not able to fire the event directly while clicking on the browser/tab close button

Please assist me on this.

Thanks