Administrators Nathan Posted July 16, 2014 Administrators Share Posted July 16, 2014 I'm using the following bootstrap method for tabs. <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li class="active"><a href="#home" role="tab" data-toggle="tab">Home</a></li> <li><a href="#profile" role="tab" data-toggle="tab">Profile</a></li> <li><a href="#messages" role="tab" data-toggle="tab">Messages</a></li> <li><a href="#settings" role="tab" data-toggle="tab">Settings</a></li> </ul> <!-- Tab panes --> <div class="tab-content"> <div class="tab-pane active" id="home">...</div> <div class="tab-pane" id="profile">...</div> <div class="tab-pane" id="messages">...</div> <div class="tab-pane" id="settings">...</div> </div> My question is how can I link to a tab so when you go to that link the page opens in that tab?http://domain.com/index.php#profile for example does not open into the profile tab. Quote Link to comment Share on other sites More sharing options...
Administrators Nathan Posted July 16, 2014 Author Administrators Share Posted July 16, 2014 Fixed by adding this just before the closing </body> tag. <script> $(function() { hashtag=window.location.hash if(hashtag!=""){ $('.nav-tabs a[href='+hashtag+']').tab('show') } }) </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.