Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
781 views
in Technique[技术] by (71.8m points)

javascript - window.open() add a rel="nofollow" attribute

Is there a way to add a rel="nofollow" attribute to the window.open() Javascript function? Or is that any way to have Google not follow a link created by Javascript or jQuery.

Update

Also, this will be a product for a client and I will not have access to their files. Any changes the robot.txt or .htaccess are off the table.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Google can read javascript links

In HTML5, the nofollow link type may only be used with a and area elements.

Since you are already using javascript.. (and can not access the robots.txt or .htaccess files), there is no reason why you couldn't use a normal (but hidden)
<a href="http://exampe.com" rel="nofollow" ...etc
(something that does support the attributes you seek, thus clearly and 'legally' indicating intention)
and use javascript to grab that URL (href attribute from the a element) to pass it to your window.open function.. However, I do not know if google wil honor this method.

Also (regarding your updated question), you can also set those directives using a meta header tag:
<meta name="robots" content="nofollow"> (and set endorsed links to rel="follow").


According to this excellent official google explanation (do give this a read or sit back and watch the talk..):

How does Google handle nofollowed links?

In general, we don't follow them. This means that Google does not transfer PageRank or anchor text across these links. Essentially, using nofollow causes us to drop the target links from our overall graph of the web. However, the target pages may still appear in our index if other sites link to them without using nofollow, or if the URLs are submitted to Google in a Sitemap. Also, it's important to note that other search engines may handle nofollow in slightly different ways.

According to wikipedia.org/wiki/Nofollow:

  • Google states that their engine takes "nofollow" literally and does not "follow" the link at all. However, experiments conducted by SEOs show conflicting results. These studies reveal that Google does follow the link, but it does not index the linked-to page, though it might be in Google's index for other reasons (such as other, non-nofollow links that point to the page).
  • Yahoo! follows it, but excludes it from their ranking calculation.
  • Bing also follows it, but excludes it from their ranking calculation.
  • Ask.com also respects the attribute.


PS: should anyone know (and be able to proof) that this wouldn't work.. leave a comment so future readers know that this workaround doesn't work as intended (and I'll amend my answer to reflect that).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...