Jump to content

document.referrer seems to not work with I.E.


michbeta
 Share

Recommended Posts

Hi all,I'm trying to know the referrer page of my html page to only permit to view my page to users that are coming from a "well known" page.The problem is that document.referrer property correctly shows the calling page with Firefox 1.0.7 but is empty with Internet Explorer.I build a very sample page:<html><body><Table border="2"> <tr> <td> Property </td> <td> Value </td> </tr> <tr> <td> document.referrer </td> <td><script> document.write("----- " + document.referrer + " -----")</script> </td> </tr> <tr> <td> document.referer </td> <td><script> document.write("----- " + document.referer + " -----")</script> </td> </tr></body></html>Firefox correctly shows:

 Property    Valuedocument.referrer  ----- http://it-m-c600:8080/WELoginAction.html -----document.referer  ----- undefined -----

but I.E. shows

Property  Value  document.referrer  -----  -----  document.referer  ----- undefined -----  

To complete the informations I'm using JBoss 4.01 SP1 as Web Server.Any help is very appreciated.Thanks,Michele

Link to comment
Share on other sites

Thanks for suggestion.I tryed it:

<html><body><Table border="2">  <tr>    <td>      Property    </td>    <td>      Value    </td>  </tr>  <tr>    <td>      document.referrer    </td>    <td><script type="text/javascript">	document.write("----- " + document.referrer + " -----")</script>    </td>  </tr>  <tr>    <td>      document.referer    </td>    <td><script type="text/javascript">	document.write("----- " + document.referer + " -----")</script>    </td>  </tr></body></html>

but the I.E. behavior is still the same, the document.referrer is empty.Thanks,Michele

Link to comment
Share on other sites

It worked ok for me in both browsers: http://scott100.atspace.com/What i did find was that if i clicked the go link it worked everytime, but if i pasted http://scott100.atspace.com/ref.htm into the address bar and clicked go it never worked.

Many thanks Scott,Your example worked also for me and directed me to the origin of the problem.The problem was originated by the calling page, where the sample page was called by:
window.open('','TestServer',"menubar=yes,scrollbars=yes,status=yes,resizable=yes,toolbar=yes,width=800, height=600);

With this function I.E. doesn't show the referrer page and, I don't know why, Firefox does show the referrer page, i'll do some other tests to try to discover the motivation.Many thanks also to other people for the receiveed help,Michele

Link to comment
Share on other sites

If you really need the refferer's URL with a window.open, just detect the parent of the current window and record its location. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...