This is because, although you allow the console to persist after page changes, the Object no longer exists - it was destroyed when you left the page. This means that it simply canβt be checked anymore, so clicking the triangle down does not help.
Try this instead to prevent the page from changing:
window.onbeforeunload = function (e) { console.log(e); return true; }
Now the page will ask you what to do. Click "Cancel" in the prompt that appears to stay on the page. Now you can view the Event in the console as desired.
The difference is that the onbeforeunload function now returns a value that is not null / undefined . The return value can be anything, even '' or false , etc. ... anything but null and undefined , and it will still cause the page to be requested before passing, which will give you the opportunity to check the event. Remember that in the absence of a return statement, JavaScript functions return undefined by default.
Whenever you cannot check something in Chrome Dev Tools, 90% of the time it happens because some action made this thing become inaccessible ... the page has moved from the moment when this object existed.
source share