在iframe上隐藏引荐来源

And*_*ndy 10 html iframe jquery

使用iframe时是否可以删除引荐来源?这里的情况:

我在http://www.mywebsite.com上有一个页面,里面有一个<iframe>.像这样:

<html>
 <head>...</head>
 <body>
  ...
<a href="#loadiframe">SHow Website</a>
  <iframe id="#loadiframe" src="http://www.iframetarget.tld">
  ...
 </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我想iframetarget.tld不包含referrer /无法看到mywebsite.com是否正在加载他们的页面.

那可能吗?

注意:iframe将使用jQuery lightbox/colorbox加载

Twy*_*wyx 10

这些答案都不对我有用,但是我在MDN上碰到了这一问题,指出将设置为referrerpolicy即可no-referrer完成此任务。

例:

<iframe src="https://www.whatismyreferer.com/" referrerpolicy="no-referrer"></iframe>
Run Code Online (Sandbox Code Playgroud)


Ngô*_*hao 7

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

有用.


Sir*_*ire 1

使用带有 javascript 位置重定向的 iframe 可以正常工作:

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

请注意,在某些浏览器上使用 HTTP 时,将始终发送最后一个引用站点,该引用站点将是拥有 iframe 的域。使用 HTTPS(和有效的证书)可确保在所有测试的浏览器上隐藏引荐来源网址。