4

I have a few elements on my page that uses onclick as the link, e.g:

<div class="service" onclick="location.href='<?php echo $fields->service_1_link; ?>'" style="cursor:pointer;">
   <img class="service" src="<?php echo $fields->service_1_image; ?>" alt="<?php echo $fields->service_1_name; ?>" height="111" width="299" border="0" />
   <div class="service-title"><h2><?php echo $fields->service_1_name; ?></h2></div>
</div>

Does this have an impact on crawlers and SEO over say a normal link?

1 Answer 1

2

This is Google's answer: http://www.google.com/support/webmasters/bin/answer.py?answer=81766

When creating your links, format them so that they'll offer a static link as well as call a JavaScript function. That way you'll have the AJAX functionality for JavaScript users, while non-JavaScript users can ignore the script and follow the link. For example:

<a href="ajax.htm?foo=32" onClick="navigate('ajax.html#foo=32'); return false">foo 32</a>

Note that the static link's URL has a parameter (?foo=32) instead of a fragment (#foo=32), which is used by the AJAX code. This is important, as search engines understand URL parameters but often ignore fragments. Since you now offer static links, users and search engines can link to the exact content that they want to share or reference.

While we're constantly improving our crawling capability, using HTML links remains a strong way to help us (as well as other search engines, mobile devices and users) better understand your site's structure.

3
  • So that pretty much says not to use it in the way I have!
    – Rob
    Commented May 25, 2011 at 10:17
  • Just noticed the updated answer - I've updated my question - how would I create that link from the code I've created? Whilst keeping it all semantically correct of course.
    – Rob
    Commented Sep 14, 2011 at 8:08
  • 1
    You seem to want an image with some text on top, both of which are clickable. You'd be better off creating a normal text link which has the image as a CSS background. That way no JS is required, and it will work for users and robots alike. Commented Sep 14, 2011 at 13:01

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.