views:

256

answers:

2

Hi.

I have a page where in Javascript I add to the location hash something like: location.hash = "initial_source=previous_referrer".

Afterwards a window.location is done in order to redirect.

However the receiver gets the referrer in his request without the hash (#) part.

Is it possible to somehow modify the URL in the initial page, without a redirect, so the final referrer is what is desired?

Thank you.

+1  A: 
location.href = redirect_url.split("#")[0] + "#" + document.referrer;
Eli Grey
The hash will never be sent to a server. It only has application on the client side.
Doug Neiner
+1  A: 

First, the hash portion of a URL is used on the client side only. It will never appear in server logs, requests, or as part of a REFERRER string.

Second, the only part of the url that can be changed without the page refreshing in the client side is the hash. So combine that with my first statement, and it becomes clear you cannot do what you are wanting.

The best course of action is to test if initial_referrer is set in the Query String. If it is not, before the page loads, redirect to the same page but add your values to the query string. Now, when your page changes via location.href = the correct referrer info will be sent.

Doug Neiner
Hmm... I understand. Was wondering if I could avoid another request.
MB