The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

AJAX initial page not loading in IE7

  • # January 16, 2013 at 8:48 am

    I’m having an issue with AJAX and I can’t seem to find a straight answer anywhere…

    I’m currently working on several sites based on the same AJAX technique, using the ba-hashchange.js plugin.

    I’m using the index page as an empty shell that once loaded then loads in the home page via AJAX, ie. becomes

    Here’s a code snippet:

    $(document).ready(function () {

    if (window.location.hash == “”) {
    window.location.hash = “home/”;


    This technique works perfectly on all browsers I’ve tested on, with the exception of IE7. In IE7 the index page loads and the URL changes to /#home/, but the content doesn’t load in. If I refresh the page, or click on a new page the content loads perfectly. It’s just the initial load that’s the problem.

    Does anyone have any experience with this or a similar issue?

    # January 16, 2013 at 5:30 pm

    Maybe you need to trigger a hash change event after you change it?

    $(document).ready(function () {

    if (window.location.hash == “”) {
    window.location.hash = “home/”;
    jQuery(window).trigger( ‘hashchange’ );


    # January 16, 2013 at 5:46 pm

    Just a slight change, both will work fine

    if(window.location.hash == “”) {
    window.location.hash = “home/”;

    # January 17, 2013 at 2:39 am

    Thanks guys, @Mottie your solution works perfectly, @karlpcrowley your solution looks neat but unfortunately it doesn’t work.

    Got this from @ChrisCoyier, might be of interest to you or anyone else who finds this thread:

    []( “”)

    # January 17, 2013 at 4:36 am

    Ha silly me, it should start with $(window) not $(document)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed