Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Last active July 25, 2024 15:37
Show Gist options
  • Save hsleonis/0dd421c57eeae61bcd2c0dbe3b887c06 to your computer and use it in GitHub Desktop.
Save hsleonis/0dd421c57eeae61bcd2c0dbe3b887c06 to your computer and use it in GitHub Desktop.
Meta referer
# HTML Inline:
To make specific link send no referer url:
<a rel="noreferrer" href="http://w3schools.com">Link</a>
# JQuery method:
<script>
$(function(){
$("a").attr('rel','noreferrer');
});
</script>
# Meta tag:
The meta referrer tag is placed in the <head> section of your HTML,
and references one of five states, which control how browsers send referrer information from your site.
The five states are:
1. None: Never pass referral data
<meta name="referrer" content="none">
2. None When Downgrade: Sends referrer information to secure HTTPS sites, but not insecure HTTP sites
<meta name="referrer" content="none-when-downgrade">
3. Origin Only: Sends the scheme, host, and port (basically, the subdomain) stripped of the full URL as a referrer, i.e. https://moz.com/example.html would simply send https://moz.com
<meta name="referrer" content="origin">
4. Origin When Cross-Origin: Sends the full URL as the referrer when the target has the same scheme, host, and port (i.e. subdomain) regardless if it's HTTP or HTTPS, while sending origin-only referral information to external sites. (note: There is a typo in the official spec. Future versions should be "origin-when-cross-origin")
<meta name="referrer" content="origin-when-crossorigin">
5. Unsafe URL: Always passes the URL string as a referrer. Note if you have any sensitive information contained in your URL, this isn't the safest option. By default, URL fragments, username, and password are automatically stripped out.
<meta name="referrer" content="unsafe-url">
@zhanglianxin
Copy link

Hey guys, according the HTML Standard, there is no none in the content values.

@philg-dev
Copy link

Hey guys, according the HTML Standard, there is no none in the content values.

I've noticed the same thing.
As an additional reference here's the MDN Specification on the topic. All Referrer Policies are listed there explicitly including short descriptions for each of them.

@silverwind
Copy link

silverwind commented Mar 23, 2024

Hey guys, according the HTML Standard, there is no none in the content values.

The gist uses the deprecated legacy names. The spec you linked is to up-to-date info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment