通过引荐来源发送位置哈希 [英] Send a location hash through a referrer
问题描述
我有一个页面,在Javascript中我添加到位置哈希,例如:
location.hash =initial_source = previous_referrer。
I have a page where in Javascript I add to the location hash something like: location.hash = "initial_source=previous_referrer".
之后a window.location完成以便重定向。
Afterwards a window.location is done in order to redirect.
然而,接收者在他的请求中获得引用者而没有哈希(#)部分。
However the receiver gets the referrer in his request without the hash (#) part.
是否可能以某种方式修改初始页面中的URL,没有重定向,所以最终的推荐人是什么?
Is it possible to somehow modify the URL in the initial page, without a redirect, so the final referrer is what is desired?
谢谢。
推荐答案
首先,URL的哈希
部分仅在客户端使用。它从不出现在服务器日志,请求中,或作为 REFERRER
字符串的一部分。
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.
其次,在客户端没有页面刷新的情况下可以更改的URL的唯一部分是哈希。所以将它与我的第一个陈述相结合,很明显你不能做你想要的。
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.
最好的做法是测试是否在查询字符串中设置了initial_referrer
。如果不是,则在页面加载之前,重定向到同一页面,但将值添加到查询字符串。现在,当您的页面通过 location.href =
更改时,将发送正确的推荐人信息。
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.
这篇关于通过引荐来源发送位置哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!