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

  • Home
  • SEARCH
  • 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 6937509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:22:19+00:00 2026-05-27T12:22:19+00:00

Im using this jquery code to switch page content on my site. It switches

  • 0

Im using this jquery code to switch page content on my site. It switches the content but it seems to flicker the page before switching to the new. I thought it might be to do with the CSS not loading through properly before it changes the content because my jquery scrollbar doesn’t load properly if i’ve clicked the link to view the page however if I refresh the page just once it seems to be working fine again.

Is there someway the code can check everything is ready before switching to avoid the glitchy flickering?

here my code for switching the page content

$(document).ready(function() {

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

$('#nav li a').click(function(){

    var toLoad = $(this).attr('href')+' #content';
    $('#content').fadeOut('fast',loadContent);
    $('#load').remove();
    $('#wrapper').append('<span id="load">LOADING...</span>');
    $('#load').fadeIn('normal');
    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
    function loadContent() {
        $('#content').load(toLoad,'',showNewContent())
    }
    function showNewContent() {
        $('#content').fadeIn('normal',hideLoader());
    }
    function hideLoader() {
        $('#load').fadeOut('normal');
    }
    return false;

});

 });
  • 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-27T12:22:20+00:00Added an answer on May 27, 2026 at 12:22 pm

    I see one issue, these two lines:

    $('#content').load(toLoad,showNewContent())
    $('#content').fadeIn('normal',hideLoader());
    

    need to be:

    $('#content').load(toLoad,showNewContent);
    $('#content').fadeIn('normal',hideLoader);
    

    If you aren’t passing any data, you can omit it, and the complete argument needs to be reference to a named function or an anonymous function. what you had was the result of executing showNewContent() which is undefined.

    function showNewContent() {
      $("body").scrollTop();
      $('#content').fadeIn('normal',hideLoader);  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this jquery code to show and hide divs on my page. As
I am using something like this: jQuery(document).keydown(function(e){ // code } For switching photos in
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;
Im using jquery 1.3.2 and this is the code: <script type=text/javascript> //<![CDATA[ jQuery(function(){ jQuery('.news_bullet
i using jquery and jquery-ui, this is my code: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML
How to make this css code cross browser compatible using jquery. this code only
I am using this JQuery Ajax Voting system guide as a rough reference but
I'm using this jQuery inline datePicker plugin sample but I don't know how to
A few days ago I posted this question: switch statement and loops using jquery/javascript
i'm using this control http://devthought.com/projects/mootools/textboxlist/ It's using JQuery Code: bit.toElement().keydown(navigate); var navigate = function

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.