Andy
Andy

Reputation: 515

Hide referrer on iframe

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

Upvotes: 15

Views: 19708

Answers (3)

Twyx
Twyx

Reputation: 729

None of these answers worked for me, but MDN's iframe reference states that setting the referrerpolicy to no-referrer will accomplish this and it worked for me. Support in older browsers will be hit or miss.

Example:

<iframe src="https://whatsmyreferer.com/" referrerpolicy="no-referrer" style="width: 100%; height: 300px;"></iframe>

Upvotes: 21

Thao Ngo
Thao Ngo

Reputation: 3771

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

It works.

Upvotes: 8

Sire
Sire

Reputation: 4348

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.

Upvotes: 1

Related Questions