Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-08-2009, 10:17 PM   PM User | #1
cheechm
Regular Coder

 
Join Date: Jan 2007
Posts: 123
Thanks: 20
Thanked 1 Time in 1 Post
cheechm is an unknown quantity at this point
jQuery Links

my javascript:
Code:
	<script type="text/javascript" charset="utf-8">
function getHash() {
        var menu_item = window.location.hash;
        return menu_item.substring(1);
}
$(document).ready(function() {
        var menu_item = getHash();
        if (menu_item == null) {
                var menu_item = 'content1';
        }
        var tabContainers = $('div#tabbed-menu > div');
        tabContainers.hide().filter('#' + menu_item).show();
        $('div#tabbed-menu ul#tabs a').removeClass('active');
        $('a#m_item_' + menu_item).addClass('active');

        $('div#tabbed-menu ul#tabs a').click(function() {
                tabContainers.hide();
                $('div#tabbed-menu ul#tabs a').removeClass('active');
                $(this).hide();
                $(this).addClass('active');
                $(this).fadeIn(150);
                tabContainers.filter(this.hash).fadeIn(150);

                return false;
        }).filter('#' + menu_item).click();

});
	</script>


HTML

Code:
        <ul id="tabs">
          <li><a href="#content1" id="m_item_content1" title="Home" class=
          "menu"><span>Home</span></a></li>

          <li><a href="#content2" id="m_item_content2" title="Portfolio" class=
          "menu"><span>Portfolio</span></a></li>

          <li><a href="#content3" id="m_item_content3" title="Services" class=
          "menu"><span>Services</span></a></li>
        </ul>

When I click the link, I want the #content1/#content2/#content3 to be appended to the URL, however jQuery stops this from happening. What can I do?

Thanks
cheechm is offline   Reply With Quote
Old 06-09-2009, 03:50 PM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
You can make it do it yourself:

Code:
$('div#tabbed-menu ul#tabs a').click(function() {
    window.location.hash = this.href;
    ...
Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Users who have thanked A1ien51 for this post:
cheechm (06-09-2009)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:14 AM.


Advertisement
Log in to turn off these ads.