Help with Script - Adding 2 URL's?

Discussion in 'Scripts' started by m1ndless, Oct 18, 2011.

  1. #1
    I have a script I am using to sort categories in my store by bestselling, but I only want it active for 2 of the categories. How would I go about adding a second URL in this script, instead of categories/shop-all I need categories-shop-all and categories/shop-best

        <script type="text/javascript">
            var currentURL = document.URL;
            var testForCategory = 0;
            var aSortExists = 0;
            var addASortURL;
            
            testForCategory = currentURL.indexOf("/categories/");
            if (testForCategory != -1) {
               aSortExists = currentURL.indexOf("?sort=");
               if (aSortExists == -1) {
                  addASortURL=currentURL+"?sort=bestselling";
                  window.location=addASortURL;
               }
            }
    </script>
    HTML:

     
    m1ndless, Oct 18, 2011 IP