在重定向期间执行javascript而不更改原始引用者

发布于 2024-07-18 02:47:23 字数 146 浏览 2 评论 0原文

我需要使用一些 javascript 客户端测试(例如,浏览器窗口尺寸)来测试点击是否有效。

但是,我希望原始点击引荐来源网址保持不变。 有没有办法可以进行重定向,执行一些 JavaScript,捕获浏览器详细信息,然后继续点击,同时保持原始引用值相同?

I need to test whether or not a click-through is valid by using some javascript client-side tests (e.g., browser window dimensions).

However, I would like the original click referrer to remain the same. Is there a way I can do a redirect, execute some javascript, capture the browser details and then continue the click-through while keeping the original referrer value the same?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浊酒尽余欢 2024-07-25 02:47:23

如果没有,则只需将引荐来源网址作为您捕获并与重定向指令一起发送回的“浏览器详细信息”之一即可。 引荐来源网址可能不会自动在客户端上可用,因此它将像这样工作:

  1. 客户端发送初始请求,可能包括引荐来源网址。
  2. 服务器动态生成客户端测试页面,包括 Javascript 变量中的引用者。
  3. 客户端收集客户端属性,包括步骤 2 中存储的引荐来源网址值。
  4. 客户端将收集的属性通过新的重定向请求发送到服务器。
  5. 服务器在某处记录引用者参数,尽管不在 HTTP 日志中,因为引用者标头的值与 Javascript 请求发送的值不同。

当然,您意识到这些都不可靠,因为这完全取决于客户端(包括步骤 1 中的 Referer 标头),并且不能保证这种情况会发生,或者如果确实发生,您获得的值是准确的。 我还质疑进行客户端检查(尤其是像窗口尺寸这样任意的检查)来确定导航请求的有效性是否明智。

If there isn't, then simply include the referrer as one of the "browser details" that you capture and send back with the redirection instruction. The referrer probably isn't available on the client automatically, so it will work like this:

  1. Client sends initial request, presumably including a referrer.
  2. Server dynamically generates the client-side-testing page, including the referrer in a Javascript variable.
  3. Client collects client attributes, including the referrer value stored in step 2.
  4. Client sends collected attributes to server with new redirection request.
  5. Server records referrer parameter somewhere, although not in the HTTP logs since the Referer header won't have the same value as what the Javascript request sent.

Of course, you realize none of this is reliable anyway because it all depends on the client including the Referer header in step 1, and there's no guarantee that will happen, or if it does happen, that the value you get is accurate. I also question the wisdom of doing client-side checks (especially of something as arbitrary as window dimensions) to determine the validity of a navigation request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文