Search code examples
htmlreferrer

Fetching the url of previous page in html?


I have an HTML page which contains an href tag.
On clicking href link, I get a new page opened.
What I want to do is fetch the url of the previous page, on which I had the href link, in my current page.

Please help. Thanks,


Solution

  • How to get previous page url using jquery

    With jQuery 'wrapper' of sorts:

    $(document).ready(function() {
       var referrer =  document.referrer;
    });
    

    Or you can just integrate var referrer = document.referrer; into your plain javascript.