-3

I have two html pages Those are 1.html and 2.html.

When I visit to 2.html from 1.html page I want to show a message in 2.html page that you have come from 1.html page.

For this purpose I am using document.referrer in my 2.html page but when I alert the message I am getting a blank popup.

I am very new to Jquery. I appreciate if any one can resolve this issue.

DarkAjax
  • 15,955
  • 11
  • 53
  • 65
PraBeen
  • 9
  • 1
  • 4
    show us your code! how are you alerting? why do you even need jQuery for this? i believe this question is inappropriately tagged! –  Aug 14 '13 at 14:42
  • You might want to do that using [cookies](http://stackoverflow.com/questions/1458724/how-to-set-unset-cookie-with-jquery). I would suggest `SESSION` if you would be using PHP. – Jeff Noel Aug 14 '13 at 14:43

2 Answers2

2

As per MDN docs

var string = document.referrer; 

Returns the URI of the page that linked to this page.

Notes:

The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
1

You can try this:-

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

Note:- document.referrer works only if the current page is loaded by clicking a link or redirecting on the previous page.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331