pushState fallback for Internet Explorer?

落花浮王杯 提交于 2019-12-12 10:48:28

问题


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);
});

回答1:


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



来源:https://stackoverflow.com/questions/6823825/pushstate-fallback-for-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!