Why does referrer disappear on drop down?

B

brett

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
 
G

Grant Wagner

brett said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top