Click to See Complete Forum and Search --> : document.referrer
bossong
07-07-2003, 02:12 PM
I'm having some difficulty with the document.referrer property in IE6. My 1st page opens a new window to display the 2nd page. It's this 2nd page that is displaying the value of document.referrer as "". Here's the code from the 1st page:
<a href="" onClick="window.open('page2.html','remote','');">Click Here</a>
This works fine in Netscape 7, Mozilla, Opera 6. Any suggestions for IE6 would be greatly appreciated.
David Harrison
07-07-2003, 02:29 PM
Have you tried using:
<a href="#" onclick="window.open('page2.html','remote','');return false;">Click Here</a>
bossong
07-07-2003, 02:50 PM
Thanks for the reply lavalamp.
Yes, I've tried what you sent and I get the same results - an empty string.
David Harrison
07-07-2003, 03:40 PM
Well, can you post all of your code for both pages (or at least a cut down version of it). Often if the code is simplified the error is easier to spot.
bossong
07-07-2003, 03:56 PM
When I dummied down the code to just a few lines and still had the problem, that's when I came looking on this site. I attached a zip file with 2 html pages. As you'll see, I can't be more basic that this.
Thanks for your help.
Originally posted by bossong
This works fine in Netscape 7, Mozilla, Opera 6. Any suggestions for IE6 would be greatly appreciated.
I do not think that document.referrer exists in Internet Explorer. It is definitely not standard. Since you're opening a new window, try something like this instead:
<a href="#" onClick="x = window.open('', 'x'); x.document.write('<script>\nalert(opener.location);\n </script>'); return false;">Testing</a>
[J]ona
Khalid Ali
07-07-2003, 04:28 PM
you do not need to use referrer to pass the value of the parent page to the child window(document.referrer may not work all the time because of its dependance on being included in the HTTP header by the webserver)
David Harrison
07-07-2003, 04:53 PM
I'm kinda glad that you two came along, I was scratching my head a bit there.
I don't suppose it would be possible to retrieve the previous URL (or URI, though I'm not sure what that is) from the history list since it is a new window, or would it?
URL: Universal Resource Locator
URI: Universal Resource Indicator
URIs are just basically the same things as URLs, but URIs usually include a query string.
If you open a new window, it automatically copies history, unless you specify copyhistory=no in the open() command (method). It's better to use opener.location.href in this case, because it will work in all browsers, and it gets the URI of the page that opened it--although, I doubt this would work in a normal page (unless it uses frames).
[J]ona
David Harrison
07-07-2003, 05:07 PM
Thanks for clearing that up.:)
A lot of answers to questions you may have can come from lots of different sites. (See links below.)
[J]ona
bossong
07-08-2003, 04:55 PM
Thank you everyone for your suggestions. Using the opener.location is what I needed.