Alex Rivera | Logout

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

Asked 2009-11-06T10:21:24.973
74

I've searched for hours, but I couldn't find a solution for this.

window.onbeforeunload = warn;

This doesn't work:

function warn (e) 
{ 
   var destination = e.href;
   alert(destination );
}

Okay, so to clear the things. If the user clicks on a link on the page itself, it is easy, because you can add an eventhandler to all of the links onclick event, but. I want to catch the address, what the user types into the url box of the browser.

Edit
Report

1 Answer

77

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.

answered 2009-11-06T10:32:02.577

Your Answer