How can I get the destination URL for the onbeforeunload event?

Solution 1:

Because it can't be done. The new location is private/sensitive information. Nobody wants you to know which sites they visit when they leave your site.

Solution 2:

If you just want to see what link destination, you can use :

document.activeElement.href 

But getting the address line destination is not possible.

I've heard of solutions where they fire off an event if the mouse moves up to the address line (to warn the user that there are unfinished processes that have not been dealt with), but this sort of hack I would never do.