在重定向期间执行javascript而不更改原始引用者
我需要使用一些 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有,则只需将引荐来源网址作为您捕获并与重定向指令一起发送回的“浏览器详细信息”之一即可。 引荐来源网址可能不会自动在客户端上可用,因此它将像这样工作:
当然,您意识到这些都不可靠,因为这完全取决于客户端(包括步骤 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:
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.