Search code examples
javascripthtmlajaxhyperlinksearch-engine

Search engines and javascript code on click of a hyperlink


I create a HTML link like this.

<a href='http://www.mywebsite.com/aPage' onclick='customFunc(); return false;'>Show Info</a>

I'm writing an ajax functionality (in customFunc) when this link is clicked and displaying data which is same as the data shown by the link in HREF tag.

Question: When search engines see my link, will they cache it? Or will they get an impression that I'm trying to do a false magic to get this page cached, and hence ignore it?

Appreciate your suggestions.


Edit: So what I interpret from this Q & A is that, (theoretically) search engines are just bothered about the href, and since it found one in the above link - it will cache this page without any troubles and it won't be worried about the things I do in the onclick JS call.

If anyone has a different opinion, please do add your comments.


Solution

  • Spiders will automatically follow each anchor in your page. If you want to avoid this behavior you have to specify rel="nofollow" for "a" tags you want to skip. You can also avoid indexing of whole pages using meta tags or robots.txt. Anyway attached event listeners are theoretically irrelevant to search engine... I took a look the SEO guide lines from google here: http://www.google.com/webmasters/docs/search-engine-optimization-starter-guide.pdf and I did not read about a scenario like your.