Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Will this javascript affect search/ranking results?

    Hi

    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:
    Code:
      function nav( productid ) {
        document.form.cat_id.value = productid;
        document.form.action = 'index.php';
        document.form.submit();
      }
    
      <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).
    Code:
      <head>
        <script language="javascript">
          function go_back() {
            document.form_back.action = '<?php echo $prev_url; ?>';
            document.form_back.submit();
          }
        </script>
      </head>
    
      <body onload="go_back()">
        <form name="form_back" method="POST" action="#">
          <input type="hidden" name="message" value="<?php echo $message; ?>" />
        </form>
      </body>
    Thank you in advance.
    Last edited by VIPStephan; 07-10-2012 at 09:19 AM. Reason: fixed code BB tags

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,706
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,706
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    Well, to keep your URLs clean there are other methods like rewrite engines (a. k. a. pretty URLs).

  • #5
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks I will look into it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •