Ali Beasley
Ali Beasley

Reputation: 77

JavaScript document.referrer

I've got two webpages one

<html>
  <body>
    <p><a href="page2.html">Link</a></p>
  </body>
</html>

And the second page.

<html>
  <body>
    <script type="text/javascript">
      document.write(document.referrer);
    </script>
  </body>
</html>

The second page is always blank, it doesn't seem to be picking up the referrer, any idea's why?

Upvotes: 3

Views: 11419

Answers (2)

565
565

Reputation: 655

Actually document.referrer which you used will return requesting page URL for all browsers except for Internet Explorer., it actually returns null in the IE.

Upvotes: 0

Pekka
Pekka

Reputation: 449395

In IE, document.referrer works only for http:// resources, not https:// and file:// ones. Maybe that is your problem.

Edit: There are even more cases in which IE doesn't pass it on.

Upvotes: 9

Related Questions