开发者

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 kno开发者_高级运维w 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);
});


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜