tags:

views:

171

answers:

3

I need to open a link from within jQuery but i need to avoid sending the referral information. In shorter words, i need to simulate rel="noreferrer"

Is it feasible?

+2  A: 

I think every browser out there automatically tacks this information onto all requests, and there's no way to directly modify it with JavaScript.

After scouring the web, you do have a couple of options though:

  1. Launch the link from within a Flash application
  2. Launch the link from within a Java applet
  3. Run your URL through a referrer cloaker/spoofer service

All options are ugly and I wouldn't recommend them for usability reasons. I'm basing this off of an old Google Answers question, but I think the answers stand.

Cory Larson
+1  A: 

You might have jQuery write a link with the rel attribute set to noreferrer, then call it with $(link_you_made).click().

sczizzo
This is an HTML5 feature, and I think only the latest Webkit browsers support it.
Cory Larson
exactly, in chrome it works perfectly. ffx 3.6 not so much. IE... no way.
andufo
+2  A: 

Not sure exactly what you mean by opening a link "from within jQuery", but setting window.location directly won't pass any referrer information.

So if you have a link that you want to pass no referral information you could do something like this:

$("a").click(function() { window.location = $(this).attr("href"); return false; });

Edit: Just did some testing & it looks like Firefox actually does pass referrer information through with a window.location change. So unfortunately this is not a complete/cross-browser solution...

Also as sczizzo points out in the comment below, there may be times where this won't be reliable (for example, I'm not sure if/how click fires when you middle click a link in Firefox to open it in a new tab).

Alconja
I'm not sure this will work as expected. The browser may bypass jQuery's event handler altogether.
sczizzo
@sczizzo: You're right (see updated answer), but I don't think there's any fool-proof way of doing it (beyond Cory Larson's suggestion of using something like flash), and I think this is the simplest answer that will at least cover the *most* situations.
Alconja