Hide referrer on iframe

无人久伴 提交于 2019-12-28 05:46:09

问题


Is it possible to remove referrer when using iframe? here the case:

I have a page at http://www.mywebsite.com with an <iframe> in it. Like this:

<html>
 <head>...</head>
 <body>
  ...
<a href="#loadiframe">SHow Website</a>
  <iframe id="#loadiframe" src="http://www.iframetarget.tld">
  ...
 </body>
</html>

i want to iframetarget.tld not contains referrer/can not see if mywebsite.com is loading their pages.

is that possible?

Note: iframe will load using jQuery lightbox/colorbox


回答1:


None of these answers worked for me, but I came across this on MDN stating that setting the referrerpolicy to no-referrer would accomplish this.

Example:

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



回答2:


<iframe id="#loadiframe" src='javascript:window.location.replace("http://www.iframetarget.tld")'>

It works.




回答3:


Using an iframe with a javascript location redirect works:

<iframe style="display:none" src="javascript:parent.location.replace('http://www.whatismyreferer.com/'+(parent.location.hash||''))">

Note that on some browsers when using HTTP, the last referrer will always be sent, which will be domain owning the iframe. Using HTTPS (and a valid certificate) ensures a hidden referrer on all browsers tested.



来源:https://stackoverflow.com/questions/15846552/hide-referrer-on-iframe

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