Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pushState fallback for Internet Explorer?

I know that IE does not support pushState, but I want a way for my users with a modern browser to enjoy the benefits while the users using older browsers don't make use of it.

Currently, the javascript code prevents my tabbed navigation from working completely in IE, which means that cannot see a lot of the content.

Anyone know a solution for my problem?

Here's my JavaScript code:

var tabContents = $(".tab_content").hide(),
                  tabs = $(".tab_nav li");

tabs.first().addClass("active").show();
tabContents.first().show();

tabs.click(function() {
    var $this = $(this), 
        activeTab = $this.find('a').attr('href');
        history.pushState(null, '', activeTab);

    if(!$this.hasClass('active')){
        $this.addClass('active').siblings().removeClass('active');
        tabContents.hide().filter(activeTab).fadeIn();
    }

    return false;
});

$(window).bind('popstate', function(){
    $.getScript(location.href);
});
like image 301
imjp Avatar asked Jul 25 '11 23:07

imjp


1 Answers

Try the jQuery BBQ: Back Button & Query Library. I've had great success using it.

like image 153
knut Avatar answered Nov 08 '22 21:11

knut