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 3945070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:58:33+00:00 2026-05-20T00:58:33+00:00

I have a site that features a fixed header, the problem is that it

  • 0

I have a site that features a “fixed” header, the problem is that it really messes up links that link further down the page a la “http://mysite.com/#lower_div_on_the_page”

Is it even possible to use javascript to do something like

if (URL has #hashtag) {starting scroll position = normal position + (my_header_height)}

Is this even possible?

EDIT:
Thanks for all the replies… really appreciated. For reference, I am DEFINITELY using jQuery… how would I do this with jQuery?

  • 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-05-20T00:58:34+00:00Added an answer on May 20, 2026 at 12:58 am

    Yes, it’s possible.

    Here are the steps you need to take:

    • Set up a DOM Loaded event handler. There’s more than one way to do this and here’s a link to a web page that explains how to do this. Also if you’re using a javascript framework such as jQuery (see .ready()) or Prototype.js (see observe extension) it would be a lot easier.

    • In the DOM loaded event handler function parse the URL (window.location) for the hashtag.

      var hashTag = window.location.href;
      hashTag = hashTag.substr(hashTag.indexOf('#') + 1);
      // now hashTag contains the portion of the URL after the hash sign

    • Then if you recognize the anchor tag compute the desired scroll location based on that element’s location in the DOM tree or whatever logic you would like to use. Again, jQuery (see .offset()) or Prototype.js (see cumulativeScrollOffset) should be able to help with determining the correct offset to scroll to.

    • Set the scroll of the page. Again jQuery (see .scrollTop()) or Prototype.js (see scrollTo) both have extensions to help with this.

    Here’s a jQuery example:

    $(document).ready(function() {
        var hashTag = window.location.href;
        if(hashTag.indexOf('#') > 0)
        {
            hashTag = hashTag.substr(hashTag.indexOf('#'));
    
            // now get the element's offset relative to the document
            var offsetTop = $(hashTag).offset().top;
    
            // and finally, scroll the document to that offset
            $(document).scrollTop(offsetTop);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that requires Windows Authentication the application obtains the credential from
I have a site that is using x509 client certificates (2 way SSL) to
I have a site that usually has news items at the top of the
I have a site that I've developed that makes decent use of Javascript, and
I have one site that is displaying html content that needs to be displayed
I have a site that I am currently working on in ASP.NET 2.0 using
We have a site that needs to (as part of our process) generate a
I have a site that will ultimately support 4 languages and 2 countries (US
I have a site that uses a couple DropDownLists that are databound. I was
I have a site that has a simple HTML button in a form. All

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.