Link Referrer in HTML

六月ゝ 毕业季﹏ 提交于 2019-12-13 08:56:24

问题


I want to ask a quetion about rel property of a tag in HTML (actually, HTML5 if that will make any difference)

I'll continue with example domain names. My website is example.com. I've a link to this page at example2.com. If I give this link with something like

<a href="example.com" referrer="referrer.com">Click me</a>

will my referrer be referrer.com or example2.com? BTW is there anything possible like that code? Giving a random referrer?

2nd one, because I think subjects are similar.

  • Is it possible to hide referrer URL?
  • If it's, what will be shown as referrer (in statistics programs or browser)?

Long story short, I want to hide and/or change the referrer.


回答1:


I believe that a meta refresh does not leave a trace of a referrer <meta http-equiv="refresh" content="0; url=http://www.example.com"> The thing here though, is getting it from an onclick (a) element, so you should, AFAIK, be able to do something like:

<a onclick="mask('http://www.example.com/')">Click me</a>

function mask(url) {
    var meta = document.createElement("meta");
    meta.setAttribute("http-equiv", "refresh");
    meta.setAttribute("content", "0; url=" + url);
}

Disclaimer: untested




回答2:


In HTML5, the link type noreferrer (link to W3C HTML5 CR) can be used:

It indicates that no referrer information is to be leaked when following the link.

If a user agent follows a link defined by an a or area element that has the noreferrer keyword, the user agent must not include a Referer (sic) HTTP header (or equivalent for other protocols) in the request.

Example use:

<a href="http://example.com/" rel="noreferrer">Click me</a>

Note: This link type is not part of W3C’s Recommendations of HTML5 and HTML 5.1, but it’s part of WHATWG’s HTML Living standard: Link type "noreferrer".



来源:https://stackoverflow.com/questions/19748880/link-referrer-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!