Can Google follow and index Javascript links
Are you wondering whether Google can detect links in Javascript? Read this article to learn how Google can parse Javascript and follow the links from it.
We had the following link from the footer of all pages of all sites in our network. <a href="javascript: window.open('http://www.indiastudychannel.com/general/PartnerSites.aspx')">Revenue Sharing sites</a>
The reason we used Javascript to open the link was to hide link from the eyes of Google and avoid any potential link spam penalty. However, it appears that Google is much smarter than we thought.
I looked at the "Links to your site" section in the Google Webmaster Tools and was shocked to see what was waiting for me there. Google reported about 1.7 million links to my site, out of which more than 50% were the links to the specific url used in the Javascript. Even though the url used in the Javascript was not really "links" in true HTML terms and SEO language, Google still parsed the Javascript and learnt that we are opening that page when user click on the link and hence Google counted them all as Links.
The Javascript links from our site network was counted by Google as links
There were about 880K links reported by Google to the same page, which were from all the other sites in our network that used Javascript instead of regular html hyperlinks.
I am not sure if the target site was penalised for having so many links. There was no manual penalty reported by Google and there is no way to know if there was an automatic, algorithmic penalty applied. Our site has recently lost a lot of traffic and hence I am assuming some sort of penalty is in effect. I figured this link issue while trying to figure out what kind of penalty may have applied on our site.What does Google's Matt Cutts say about links from Javascript
Watch this video by Matt Cutts and see his views on Google parsing the Javascript in webpages.
According to Matt Cutts, Google will try to parse and understand Javascript in the webpages and he does not recommend we doing anything to block Google from it since it is better to allow Google to understand what is in the page.
What is the solution?
The mistake I did was, I assumed Google wouldn't parse the Javascript and wouldn't consider the links in the script. If you want to use links from Javascript, you may move it to a .js file and stop Google from indexing the file, which Google does not recommend.
An alternative solution is to use rel="nofollow" attribute, even if you are using Javascript to open the url.How to use rel="nofollow" attribute when you use Javascript to open urls
You can use the rel="nofollow" attribute, even if you are using Javascript to open hyperlinks. Here is an example using my own case above.<a href="javascript: window.open('http://www.indiastudychannel.com/general/PartnerSites.aspx')" rel="nofollow">Revenue Sharing sites</a>
So, contrary to the common belief that Javascript links are ignored by Google, this experience shows that Google can understand Javascript and also follow the links from there.
Read Why Ajax is the Cooler Cousin of JavaScript?
Just wanted to thank you for this article. I saw a Matt Cutts video listing ways to stop google indexing Javascript links but it did not explain clearly if rel = nofollow should be added to the normal html a tag or if it should go elsewhere.
Have you tested that adding rel=nofollow to the A tag works?