Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:08:13+00:00 2026-06-14T07:08:13+00:00

HTML: <ul class=nav nav-tabs> <li><a href=#home data-toggle=tab>Home</a></li> <li><a href=#profile data-toggle=tab>Profile</a></li> <li><a href=#messages data-toggle=tab>Messages</a></li> <li><a

  • 0

HTML:

<ul class="nav nav-tabs">
  <li><a href="#home" data-toggle="tab">Home</a></li>
  <li><a href="#profile" data-toggle="tab">Profile</a></li>
  <li><a href="#messages" data-toggle="tab">Messages</a></li>
  <li><a href="#settings" data-toggle="tab">Settings</a></li>
</ul>

<div class="tab-content">
                <div class="tab-pane active" id="home">
                    <p>a</p>
                    <p>very</p>
                    <p>long</p>
                    <p>content</p>
                    <p>string</p>
                    <p>to</p>
                    <p>simulate</p>
                    <p>very</p>
                    <p>long</p>
                    <p>paragraphs</p>
                    <p>for</p>
                    <p>testing</p>
                    <p>purposes</p>
                    <p>only</p>
                    <p>thank</p>
                    <p>you</p>
                    <p>and</p>
                    <p>good</p>
                    <p>morning</p>
                    <p>to</p>
                    <p>you</p>
                    <p>foo</p>
                    <p>bar</p>
                </div>
                <div class="tab-pane" id="profile">
                   Profile Content Here
                </div>
                <div class="tab-pane" id="messages">
                    Messages Content Here
                </div>
                <div class="tab-pane" id="settings">
                    Settings Content Here
                </div>
            </div>

Javascript

if (location.hash !== '')
    {
        $('a[href="' + location.hash + '"]').tab('show');
    }

    $('a[data-toggle="tab"]').on('shown', function(e) {
          return location.hash = $(e.target).attr('href').substr(1);
    });

    $(window).on("hashchange", function(){
        $('a[href="' + location.hash + '"]').tab('show');
    });​

I have code and demo here

Tabs is working fine when clicking on the other tabs other than #home. However, if I click on a tab with long content that is more than a page, the page focuses on the div which causes the the viewport to home in on the respective div. Aesthetically, I would prefer that the page don’t home in to that div.

Is there a way to prevent this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:08:14+00:00Added an answer on June 14, 2026 at 7:08 am

    Add a focus() call to the shown event handler before it returns.

    $('a[data-toggle="tab"]').on('shown', function(e) {
        location.hash = $(e.target).attr('href').substr(1);
        $(this).focus();
        return false; // or true - whichever you prefer
    });
    

    see the fiddle – http://jsfiddle.net/nVU3r/3/

    Updated the fiddle. I have added $() around the element to permit focus call. When settings the location.hash the browser automatically moves to the element. We simply switch it back.

    If you don’t need the location.hash then you can remove the entire this entire code block and newly presented tab wont get focused.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple nav bar like so: <ul class=nav> <li><a href=<%= index_url %>>Home</a></li>
I am using web client class to HTML data from a web page. Now
cms is generating content in this format. <ul id=slide_nav class=tabs> <a name=ctn2363_2465 id=ctn2363_2465 class=hidden></a><li
I think this example would make it clear. My HTML is this: <li class='nav-active'><span
Having a weird devise problem. The code looks like this: %ul.nav.nav-tabs %li.active %a{ :href
I am using TW Bootstrap's tabs to tab through content on my clients' site
When I create an HTML div element with no content, it disappears. When the
I have a nav menu with 2 tabs/links in the show.html.erb file, in UsersController.rb
I'm working on an HTML class in PHP, so that we can keep all
I'm trying to compare two numbers, and add an HTML class to the large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.