Reputation: 8463
For instance my current url is
http://www.sample.com/check/?code=1
Web page under this url contains a link
<a href="http://www.sample.com/check/?code=2">Code2</a>
When this link is clicked it takes to http://www.sample.com/check/?code=2
Question:
Under the web page displayed under http://www.sample.com/check/?code=2
i have to fetch the url from which this page had came from. How to do this.
Thanks in advance...
Upvotes: 1
Views: 5184
Reputation: 708166
If you control the original page, then you could put a source in the URL like this:
<a href="http://www.sample.com/check/?code=2&scr=http://foo.com/xxxx">Code2</a>
and you could parse that out of the URL in the 2nd page.
Or you can look at document.referrer
in the 2nd page and see if it contains the value you want. See https://developer.mozilla.org/en/document.referrer for info about the referrer.
Upvotes: 1
Reputation: 3931
<script type="text/javascript">
alert(document.referrer);
</script>
Upvotes: 4