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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:34:14+00:00 2026-06-01T21:34:14+00:00

Maybe this isn’t possible with ASP.NET MVC because I can not find an answer.

  • 0

Maybe this isn’t possible with ASP.NET MVC because I can not find an answer. What I want to do is click a link which will load the target page then scroll to anchor on that page. A perfect example of this was answered in this question.

However how do I get this to work with JavaScript/jQuery?

UPDATE:With this code everything is working except for the setTimeOut definition. It just keeps running the script until I click stop, then if scrolls down to the anchor. Why is that?

var jump = function (e) {
    if (e) {
        e.preventDefault();
        var target = $(this).attr("href");
    } else {
        var target = location.hash;
    }

    $('html,body').animate(
{
   scrollTop: $(target).offset().top
}, 2000, function () {
   location.hash = target;
});

}

$('html, body').hide();
$(document).ready(function () {
    $('a[href^=#]').bind("click", jump);

    if (location.hash) {
        setTimeout(function () {
            $('html, body').scrollTop(0).show();
            jump();
        }, 0);
    } else {
        $('html, body').show();
    }        

});
  • 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-01T21:34:16+00:00Added an answer on June 1, 2026 at 9:34 pm

    I know nothing about asp.net, but this is what I think is happening:

    ASP.NET MVC’s MicrosoftAjax module reloads a page on initialization if hash is supplied in location.

    The MVC framework, namely its MicrosoftAjax component, attempts some browser’s history management and it uses the hash portion of URL for that matter, which is a valid standard procedure, up until this point. At initialization time, the Sys$_Application$initialize() through _navigate() engages the _raiseNavigate() application method. And this one does some dances specifically for Firefox:

    // Name:        MicrosoftAjax.debug.js
    // Assembly:    System.Web.Extensions
    // Version:     4.0.0.0
    // FileVersion: 4.0.20526.0
    
    if ((Sys.Browser.agent === Sys.Browser.Firefox) && window.location.hash &&
        (!window.frameElement || window.top.location.hash)) {
        window.history.go(0);
    }
    

    Three conditions:

    1. browser is Firefox
    2. address carries a hash portion after the URL
    3. it is not inside a frame

    All of them pass in your case and the beast is unleashed:

    window.history.go(0);
    

    That instructs browser’s history manager to go back or forward by the distance given as argument. -2 goes one step back, 1 goes one step forward. Thus 0 effectively reloads the page. And does it on every page load for any hash given to the page. Can’t think of any valid purpose of this line there anyway…

    Sure enough if I comment out those rather hairy and pointless lines, it works! It seems to be a backward compatibility attempt for Firefox 3.5 or lower, so I would say remove it or better update your MVC.

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

Sidebar

Related Questions

I'm pretty shocked I can't find an answer to this (maybe there isn't one).
Maybe this has been answered before, but I was not able to find it.
I know next to nothing about SharePoint, so maybe this isn't something you can/should
Maybe this isn't possible, I've never seen it myself, but thought I'd ask. If
It maybe sleep deprivation but I cannot understand why this isn't working. I want
Maybe this isn't really feasible. But basically, I've been developing a snippet-sharing website and
Maybe this is a simple problem, but I am just not seeing it :)
Ok, maybe this isn't so amazing considering I don't really understand how the debugger
Maybe I am being stupid, but this isn't making sense to me... I have
Maybe this isn't even a valid question, so any help would be good.

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.