Satya Kalluri
Satya Kalluri

Reputation: 5214

jQuery : How to find the url that the user has typed in the browsers address-bar during body-unload event?

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 :

  1. BeforeUnload

  2. 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

Answers (2)

qoda
qoda

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

Bas Slagter
Bas Slagter

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

Related Questions