Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
So that pretty much says not to use it in the way I have! –  Rob May 25 '11 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 Sep 14 '11 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. –  Tim Fountain Sep 14 '11 at 13:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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