By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,517 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,517 IT Pros & Developers. It's quick & easy.

Why does referrer disappear on drop down?

P: n/a
When I use this code:

<select name="status" onChange =
"location.href=this.options[this.selectedIndex].value">
<option value="mypage.htm">Select View</option>
</select>

I don't have a referrer. When I click an anchor tag link, the
resulting page does have a referrer. How can I get a referrer using
the above JS?

Thanks,
Brett

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"brett" <ac*****@cygen.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
When I use this code:

<select name="status" onChange =
"location.href=this.options[this.selectedIndex].value">
<option value="mypage.htm">Select View</option>
</select>

I don't have a referrer. When I click an anchor tag link, the
resulting page does have a referrer. How can I get a referrer using
the above JS?
Setting location.href in some user agents does not send the HTTP_REFERER
header. But since the referrer information is unreliable anyway <url:
http://www.datatrendsoftware.com/spoof.html />, it isn't really that big
a deal.

If you absolutely must pass it, and you are relying on JavaScript
anyway, then you could do:

<select
name="status"
onchange="
location.href =
this.options[this.selectedIndex].value +
'?referer=' + location.href;
"


(split across multiple lines for readability only)

Note that you'll need special handling on the next page (in either
client- or server-side code) to retrieve the referrer. The standard ways
of getting the value ( $_SERVER['http_referer'] in PHP for example)
won't work.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.