Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

javascript - Send a location hash through a referrer

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...