Load external website in iframe but without sending HTTP_REFERER

ぃ、小莉子 提交于 2019-12-11 13:33:41

问题


Is it possible to load an external website in iframe but without sending HTTP_REFERER ? I just don't want be tracked.

If it is possible then how and if not then is there any workaround using divs or anything else ?

For anchor tag with external link jQuery("a").attr('rel','noreferrer'); is working, but for iframe I've failed to make it work.

Is there any script( js or jQuery ) to make it work ?


回答1:


Here's a very simple solution. Use this in you document <head> tag and you are good to go :D

<meta name="referrer" content="none">

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

  2. None When Downgrade: Sends referrer information to secure HTTPS sites, but not insecure HTTP sites

  3. Origin Only: Sends the scheme, host, and port (basically, the subdomain) stripped of the full URL as a referrer, i.e. moz.com/example.html would simply send moz.com

  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")

  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.

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta




回答2:


I came across this on MDN stating that setting the referrerpolicy attribute to no-referrer would accomplish this.

Example:

<iframe src="https://www.whatismyreferer.com/" referrerpolicy="no-referrer"></iframe>


来源:https://stackoverflow.com/questions/34543006/load-external-website-in-iframe-but-without-sending-http-referer

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