【问题标题】:how embed origin site address in a link in html?如何在html中的链接中嵌入源站地址?
【发布时间】:2020-12-24 10:34:46
【问题描述】:

假设在网站的页脚中有一个类似<a href="mysite.com">click here</a> 的链接。 有什么方法可以更改此链接,以便 mysite.com 网站的管理员可以检测到该用户来自哪个站点?

谢谢。

【问题讨论】:

  • 只需添加一些参数,例如mysite.com?whoIam=itsMe。显然,目标站点的管理员必须检查请求日志,或者他需要为该特定参数创建一些代码并跟踪它。

标签: html referrer


【解决方案1】:

你可以这样做

<a href="https://example.com" 
onclick="this.href = 'https://example.com/?ref='+encodeURIComponent(location.host)">click here</a>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-21
    • 1970-01-01
    • 1970-01-01
    • 2013-07-05
    • 2010-10-28
    • 1970-01-01
    相关资源
    最近更新 更多