Reputation: 5214
I have a web page with URL say http://www.crunchbase.com
Now, if the user goes away from this website by typing a new URL in address bar, say http://www.techcrunch.com, and hits submit, the following Javascript-events trigger :
BeforeUnload
OnUnload
.
In both these events, fetching the document.location gives only old-URL (http//www.crunchbase.com). But, Is there a way to know the new URL (http://www.techcrunch.com) that the user has entered?
Upvotes: 2
Views: 1223
Reputation: 46
There isn't any way of achieving this as for security and privacy reasons. The window.location is not determined by the address bar.
Upvotes: 1
Reputation: 9929
I don't think so. If the user enters a new url and navigates to that page, it is that page that gets in control. So, from the moment the user hits 'enter' in the address bar, you are lost. Before that, you are in control but only within the scope of your own site.
Upvotes: 1