Reputation: 385
I know I can get the current URL in javascript with window.location.href, however is it possible to get the requested page URL as the user is leaving that page? I want to send it to ajax in the window.onunload function and do something with it in my session variables. Thanks
Upvotes: 0
Views: 136
Reputation: 4102
If a user is leaving your page via one of the links on your website, you can get the href attribute value with Javascript, but if he decides to type in new url address in address bar and hit enter, you won't be able to get this information using Javascript.
Upvotes: 1