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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:50:37+00:00 2026-05-23T16:50:37+00:00

For fun I tried to animate an object and load content after it, because

  • 0

For fun I tried to animate an object and load content after it, because I loved the idea.
It’s working but theres a bug in the jQuery I guess, which I can’t handle currently.
The Divbox ‘nav’ should animate to the top and STICK there! after that it should load the content. It’s working but the nav box wont stick to the top in Firefox 4.0. In Firefox 3.5 there is no Animation! Firefox 5.0 and Opera 11 is working for me. Anyone got a solution for this Problem?

jQuery Code:

jQuery.fn.center = function(centerCallback) {
    this.css("position", "absolute");
    this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
    this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
    if (centerCallback != undefined) {
        centerCallback(this);
        return this;
    }
}

$(document).ready(function() {
    var hash = window.location.hash.substr(1);
    var href = $('#main_navigation a').each(function() {
        var href = $(this).attr('href');
        if (hash == href.substr(0, href.length - 5)) {
            var toLoad = hash + '.html #content';
            $('#content').load(toLoad)
        }
    });


    $('#main_navigation a').click(function() {
        var toLoad = $(this).attr('href') + ' #content';
        $('#content').hide('fast', loadContent);
        window.location.hash = $(this).attr('href').substr(0, $(this).attr('href').length - 5);

        function loadContent() {
            $('#content').load(toLoad, '', showNewContent())
        }

        function showNewContent() {
            $('#content').show('normal', hideLoader());
        }

        function hideLoader() {
            $('#load').fadeOut('normal');
        }
        return false;

    });
});


var navi_switch = true;
var content_container = 'test';
$(document).ready(function() {
    $('#wrapper').center(function() {
        $('#main_navigation').css("top", (parseInt($('#main_navigation').parent().height()) - parseInt($('#main_navigation').height())) / 2 + "px");
    });

    $('#main_navigation a').click(function() {
        var attr = $(this).attr('href');
        if (navi_switch) {
            $('#main_navigation').animate({
                top: '0'
            }, 500, function() {
                navi_switch = false;
                $('#content').load(attr);
            });
        } else {
            $('#content').load(attr);
        }


        return false;
    });
});

Greetings

  • 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-23T16:50:37+00:00Added an answer on May 23, 2026 at 4:50 pm

    Lets see now …

    1. Two click handlers assign to the a elements, both making ajax requests to different urls.
    2. $('#content').load(attr); does not use the #content to filter the results..

    also

    function loadContent() {  
        $('#content').load(toLoad,'',showNewContent())  
    }  
    function showNewContent() {  
        $('#content').show('normal',hideLoader());  
    } 
    

    should really be

    function loadContent() {  
        $('#content').load(toLoad,'',showNewContent /*no parenthesis here, just passing a callback */)  
    }  
    function showNewContent() {  
        $('#content').show('normal',hideLoader /*no parenthesis here, just passing a callback */);  
    }  
    

    Fix these issues for start, and come back if the issues persist..


    Merged Parts

    jQuery.fn.center = function(centerCallback) {
        this.css("position", "absolute");
        this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
        this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
        if (centerCallback != undefined) {
            centerCallback(this);
            return this;
        }
    }
    
    var navi_switch = true;
    var content_container = 'test';
    
    $(document).ready(function() {
    
        loadInitialContent(); // call our function to load the initial content based on url hash
        $('#wrapper').center(function() {
            $('#main_navigation').css("top", (parseInt($('#main_navigation').parent().height()) - parseInt($('#main_navigation').height())) / 2 + "px");
        });
    
        $('#main_navigation a').click(function() {
            var href = $(this).attr('href'); // get the href
            window.location.hash = href.substr(0, href.length - 5); // change the hash of the url
            href += ' #content'; // add the #content filter to the href
            if (navi_switch) {
                $('#main_navigation').animate({
                    top: '0'
                }, 500, function() {
                    navi_switch = false;
                    $('#content').hide('fast', function(){
                       $(this).load(href, function(){
                          $(this).show('normal', function(){
                              $('#load').fadeOut('normal');
                          });
                       });
                    });
    
                });
            } else {
                   $('#content').hide('fast', function(){
                       $(this).load(href, function(){
                          $(this).show('normal', function(){
                              $('#load').fadeOut('normal');
                          });
                       });
                    });
            }
    
            return false;
        });
    });
    
    function loadInitialContent() {
        var hash = window.location.hash.substr(1);
        var href = $('#main_navigation a[href^="' + hash + '."]').attr('href') + ' #content';
        $('#content').load(href);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on some jQuery widget for work/fun lately ( github ) and
I am somewhat new to jQuery but have been having fun trying learn about
I brute-forced summing of all primes under 2000000. After that, just for fun I
I am trying to have some fun with dashboard widgets, so I tried a
Now here's a fun problem. I have an object array as the following: objRequests
So I'm working on a fun little program and ran across this rather interesting
have tried to use this my own function on FBJS: function addEvent(event,fun,pars){ pars.event=event; pars.listen=function(){
Has anyone tried deploying unsafe code in Azure? I'm working with code containing unsafe
I'm working on a nice long regular expression (for fun, yeah I know...) and
I'm currently learning C# and its fun so far, but I have hit a

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.