michbeta Posted April 11, 2006 Share Posted April 11, 2006 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 More sharing options...
Little Goat Posted April 11, 2006 Share Posted April 11, 2006 well first put this in your script tags: <script type="text/javascript"> that might be the problem. LG Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 11, 2006 Share Posted April 11, 2006 Yes, you should use a full script tag, including the type attribute. Link to comment Share on other sites More sharing options...
michbeta Posted April 11, 2006 Author Share Posted April 11, 2006 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 More sharing options...
scott100 Posted April 11, 2006 Share Posted April 11, 2006 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. Link to comment Share on other sites More sharing options...
aspnetguy Posted April 12, 2006 Share Posted April 12, 2006 thats because if you are pasting the url int the address box there is no referer.the referer is the page that you just came from(ie clicked a link/button on) Link to comment Share on other sites More sharing options...
michbeta Posted April 13, 2006 Author Share Posted April 13, 2006 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.<{POST_SNAPBACK}> 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 More sharing options...
Chocolate570 Posted April 14, 2006 Share Posted April 14, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now