0

I am working with the header component for a .net cart AbleCommerce. The active link effect will only be used in the header. I have a script that is working for all webpages, but it fails to apply to scriptlets. Ex. "About Us" is a webpage, the script functions as expected. "Home" is a default page that exists as a scriptlet (not a webpage created via admin) and teh script below fails.

I have tried several different variation of jquery and nvolicity (yuck!) with the same results described above. I tried using a full path url "http://wwwpage.aspx" instead of something like "~/page.aspx". I tried adding a reference to the ID within the links themselves.

There are only two header nav links that are non-webpages (again created as a webpage in the cart's admin) that I need to get this working for.

The script that works for webpages is:

<script type="text/javascript" src="../../../../js/jquery-1.3.2.min.js">
jQuery(function( $ ){
    $('a.next').click(function(){
        $('#nav_header a').removeClass('CurrentLink');
        var fragment = this.getAttribute('href');
        $('#nav_header a[href=' + fragment + ']').toggleClass('CurrentLink');
    });
});
</script>

Any thoughts, ideas or resources would be greatly appreciated. I know that this is probably not the ideal .net sort of solution, the approach is what is required of me. Trying to learn as fast as I can...

Thanks!! Julie

Full HTML code:

<!--
<Description>
Displays the standard store header.
</Description>
-->
<table id="storeHeader" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="3" height="18"></td>
  </tr>
  <tr>
    <td> <div style="position:relative; left:-30px;"><a href="~/Default.aspx"><img src="../../../../App_Themes/alliedHealth/images/alliedHealthBrand1.png" width="542" height="54" border="0" /></a></div>


 </td>

    <td><div class="alliedPhone">Call 888.818.9696</div></td>
    <td align="right">

   <div class="shortcuts">
   <a href="~/Basket.aspx" class="basket">Shopping Cart</a>&nbsp;|&nbsp;<a href="~/Members/MyAccount.aspx" class="acct">Account</a>&nbsp;|&nbsp;                #if($customer.IsAnonymous)
                    <a href="~/Login.aspx" class="login">Login</a>
                #else
                    <a href="~/Logout.aspx" class="login">Logout</a>
                #end


      </div> 

    </td>
  </tr>
  <tr>
    <td colspan="3" height="25"></td>
  </tr>
</table>

<style type="text/css">

.CurrentLink a
{
    color:#f8981d;
}


</style> 



<script type="text/javascript" src="../../../../js/jquery-1.3.2.min.js">
jQuery(function( $ ){
$('a.next').click(function(){
$('#nav_header a').removeClass('CurrentLink');
var fragment = this.getAttribute('href');
$('#nav_header a[href=' + fragment + ']').toggleClass('CurrentLink');
});
});
</script>

<script type="text/javascript">

function select_nav() {
   var nav_links = document.getElementById('#nav_header')
     .getElementsByTagName('a');
   var selected = location.pathname;

   for (var i = 0; i < nav_links.length; i++) {
     var link = nav_links[i].pathname;

     // fiddle IE's view of the link
     if (link.substring(0, 1) != '/')
       link = '/' + link;

     if (link == selected)
       nav_links[i].setAttribute(cattr, 'CurrentLink');
   }
 }

 window.onload = function() {
   select_nav();
 };
</script>

 <div class="w2mHeaderLowerNavBg">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td align="left" width="30"></td>
    <td align="left" > 
    <div class="w2mHeaderLowerNav" id="nav_header">
    <a href="~/Default.aspx" >Home</a>

    <a href="~/About-W7.aspx" >About</a>

    <a href="~/Service-and-Parts-W4.aspx" >Service &amp; Parts</a>

    <a href="~/Consulting-W6.aspx" >Consulting</a>

    <a href="~/Financing-W5.aspx" >Financing</a>

    <a href="~/Contact-W3C2.aspx" >Contact</a>

    <a href="~/AdvancedSearch.aspx" >Advanced Search</a>
    </div>

    </td>
    <td align="right" width="232"> <div class="search">
                [[ConLib:SimpleSearch]]
            </div></td>
    <td align="right" width="12"></td>
  </tr>
</table>
</div>
Julie Carlson
  • 81
  • 2
  • 7
  • Can you define fails? Also, edit your question to include your html please. – mrtsherman Feb 20 '12 at 13:45
  • By fail, I mean nothing breaks or shows an error. A link to one of the two scriptlets in the top nav simply does not respond to the jquery by applying the rule for an active state. It works for all other links, but those are all webpages created in admin. I hope that helps. Here is a link: http://209.242.46.89/Default.aspx – Julie Carlson Feb 20 '12 at 16:44

1 Answers1

0

Problem maybe with your jquery path. Either use absolute path in src attribute or try using ~

src="~/js/jquery-1.3.2.min.js"
Mazhar Qayyum
  • 630
  • 7
  • 22