PDA

View Full Version : document.referrer empty


Maarten
10-16-2002, 10:42 AM
Dear all,

When redirecting to another page by a command like:
top.location.href="index.htm"', it turns out that, at least
in IE, document.referrer is empty. This is also the case
with <a onclick='top.location.href="index.htm"'>.

Since I need the URL of the "referrer" my question is: is
there a way that works for both NS and IE to obtain
the URL of the "referrer", irrespective of the way the referrer
takes us to the actual document?

Thanks in advance,

Maarten


P.S. I am asking because I want to redirect users form an
unframed document to a page that puts the url of the
document to the right frame. I rather not want to do this by
redirecting to framepage.html?URLofrequesteddocument
because this show up in the location bar all the time. If this
problem can be solved in quite another way, I would be
glad to hear

requestcode
10-16-2002, 01:25 PM
I believe document.referrer will be empty if they access the page from their bookmarks or enter the URL into the location bar. I don't think that will work.

beetle
10-16-2002, 03:16 PM
I did a script for that once...now where did I put it...ah yes, here it is (http://www.peterbailey.net/js/superframes.js)

It's a bit old (over a year...), but should work for the most part...you can at least see the algorithm I had to use for cookie/referrer checking...

BrainJar
10-16-2002, 03:48 PM
I've had problems with users behind a firewall. Sometimes the firewall will strip the referer header.

Also, if you open the file locally (file:///) or from your local webserver (http://localhost or http://127.0.0.1) most browser will not send a referer - a good idea since you wouldn't want web sites knowing your local file paths.