View Full Version : window.location and http_referer
08-31-2004, 08:52 PM
Anyone know why when you do a
window.location = "new_url" the http_referer environmental is not set?
i've pretty much got everything working except this little bit..
08-31-2004, 10:04 PM
Is this with just one browser or did you test it on several browsers?
08-31-2004, 11:11 PM
i tried it on mozilla/NS7 and IE5 and IE6
i think it has something to do with the fact that window.location may not be treated the same as a link.. its not actually linking to a page it is just changing the window.location to a new value.
09-01-2004, 07:40 AM
My testing in IE6 shows the behavior you're suspecting. But in Firefox, it runs fine, the referer shows in all instances.
In IE6, using location.href will not set the HTTP_REFERER. Normal links will do. But the funny thing is using window.open(url, '_self') will show the referer but only if the last previously clicked is a normal link.
Try running this simple demo.
<input type="button" value="Open using location.href" onclick="location.href='page2.asp'" />
<input type="button" value="Open using window.open(url, _self)" onclick="window.open('page2.asp', '_self')" />
<input type="button" value="Open in new window" onclick="window.open('page2.asp', '_blank')" />
<a href="page2.asp">page 2 link</a>
response.write "Referer:" & request.servervariables("HTTP_REFERER")
09-01-2004, 06:17 PM
As I suspected (but didn't have the time to check), it's a browser implementation problem. Unfortunately that means you can't do anything to fix it, you have to find a way to work around it.
09-01-2004, 09:03 PM
yea i just ended up passing it through the QUERY_STRING, its a little undesirable but that is the way it goes..
it is essentially just a convienence to be able to send the user back to their original page when they go through some login steps..
09-01-2004, 10:13 PM
Not just convenient, it's polite. Good for you.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.