I have the following anchor code on my site:

<a href="/mypage.html" onclick="return getMyPageWithAjax();" >My Page</a>

For human users, the onclick will get the data with AJAX without page refresh.

Currently what is the behaviour of Googlebot when it sees that link? Will it ignore onclick and directly go to page given in href or handle onclick or do both when it indexes my website?

The same question for Yahoo and Bing but most important is Google.

Is there a way I can tell the bot, ignore onclick and go to href or vice versa?

What would be the behaviour of the bot if the anchor had no href attribute or href="#" and just onclick attribute with above value?

1 Answer 1


Googlebot knows how to fetch and page built with JavaScript and AJAX. However, Googlebot doesn't try to click everywhere on the page just to see what will happen. The best way to get Google to crawl other pages is to to use the <a href="/mypage.html" code.

Google will also identify URLs in bits of JavaScript. The following code will get Googlebot to discover and crawl /mypage.html:

var url = '/mypage.html';

However, Googlebot uses heuristics to scan the JavaScript code for URLs like that. It doesn't try to click on anything. It will look at all your string literals and crawl anything that looks enough like a URL. Any string literal without spaces that has a slash or ends in .html will get crawled by Google.

When Googlebot identifies URLs in JavaScript it isn't clear that it uses them exactly like href links. It will report them as crawl errors in Search Console if they have problems such as 404 errors. However, it may or may not assign link juice to them and pass SEO signals like anchor text across them.

There is no way that I know of to have Googlebot ignore the hrefs nor is there a way to get Googlebot to ignore JavaScript string literals that look like URLs. There is no way to tell Googlebot to click on elements of the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.