onclickseoanchor

SEO and anchor link "onclick"


I'm working on a page where links are added with JavaScript. This is according to my knowledge not optimal when it comes to SEO.

Example added by DOM-manipulation/jQuery:

<a href="" onclick="openPage(231);">Go To Page</a>

So I have added a correct href attribute and creates the tag server side, like this:

<a href="?color=red#pageOne" onclick="openPage(231);return false;">Go To Page</a>

Will google and other search engines accept the href even though the navigation is done by the JavaScript function, or will anchor tag be "down-prioritized" due to containing a link that cant be accessed? The link itself will lead to the same page as the JavaScript event. However it is not actually used in this case.


Solution

  • Crawlers will see the href links and try to use them. Google crawlers are capable of using javascript to follow links as per the blog here with few gotchas. http://www.searchenginepeople.com/blog/onclick.html. If you want your link to crawled, then there are other alternatives as google will follow text urls on page source.