View Full Version : Will this javascript affect search/ranking results?

07-10-2012, 09:51 AM

This maybe obvious to most of you but please bare with me.

Will using the following javascript affect search/ranking results? If so, what should I do instead?

1. User clicks on a product link to see product details:

function nav( productid ) {
document.form.cat_id.value = productid;
document.form.action = 'index.php';

<a href="javascript:nav('.$productid.');">'.$productname.'</a>

2. Used on a processing script page. Used to go back to the previous page. (Usually back to a form, from a processing script).

<script language="javascript">
function go_back() {
document.form_back.action = '<?php echo $prev_url; ?>';

<body onload="go_back()">
<form name="form_back" method="POST" action="#">
<input type="hidden" name="message" value="<?php echo $message; ?>" />

Thank you in advance.

07-10-2012, 10:23 AM
In code example one search engine spiders might not be able to follow the link. Also, from a user interaction perspective this is awful. HTML has been invented for a good reason. If JavaScript is disabled, the link is non-functional, so what’s the point?

What you should do, and what I can’t stress enough, is make your site functional without JavaScript and only add JS as enhancement. Why are you doing this with a form anyway? Why not just have a plain link to the product detail page? I think you are way overcomplicating things.

07-10-2012, 11:32 AM
Thanks for your reply.
The reason why I used the method in point 1 was because all products come dynamically from the database using php and I don't want to send the product id in the url to the product detail page (as I am want to keep all urls clean).

Im quite new to this so if you could suggest a different solution which would achieve my objective it would be most appreciated.

Many thanks

07-10-2012, 11:42 AM
Well, to keep your URLs clean there are other methods like rewrite engines (http://en.wikipedia.org/wiki/Rewrite_engine) (a. k. a. pretty URLs (http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/)).

07-10-2012, 12:34 PM
Thanks I will look into it.