• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 808
  • Last Modified:

Document.referrer script working in Firefox but not IE

I'm trying to create a simple script to verify the referrer URL, then if the referrer URL is what I specify display the content.  So far this script works fine in Firefox, but does not seem to work in IE.

(linkaccess.html)
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test</title>
<script>
if (document.referrer != "http://www.domain.com/linksource.html"){
      alert ("cannot find link")
      location.href = "protect.html";
      }
else {alert ("found it hurray")}
</script>
</head>

<body>
test
</body>

</html>

(linksource.html)

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test</title>
</head>

<body>
<a href="linkaccess.html">test</a>
</body>

</html>

(protect.html)

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test</title>
</head>

<body>
You don't belong here
</body>

</html>
0
deek22
Asked:
deek22
  • 3
  • 2
1 Solution
 
ZvonkoSystems architectCommented:
document.referrer  does not work on local file system.
And it is better to check the referrer on server side before responding to request with a page but with a response.redirect

The scripting on browser side is NOT realy a protect.
0
 
deek22Author Commented:
Thanks for the pointer :  I used this link to help protect my page:

http://blogs.msdn.com/lisawoll/archive/2005/06/24/432429.aspx


Thx
0
 
ZvonkoSystems architectCommented:
Why the grading B?
0
 
deek22Author Commented:
Well, I guess a Grade A would have been a more comprehensive answer with maybe some links to help understand the response.redirect concept.  Please forgive me if I sound a bit picky.

I greatly appreciate your help,


0
 
ZvonkoSystems architectCommented:
No problem, it is your question and your opinion.
But be aware that my opinion also changes depending on feedback I get ;-)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now