【问题标题】:pushState fallback for Internet Explorer?Internet Explorer 的 pushState 后备?
【发布时间】:2011-07-25 23:55:19
【问题描述】:

我知道 IE 不支持 pushState,但我希望我的用户使用现代浏览器享受好处,而使用旧浏览器的用户不使用它。

目前,javascript 代码阻止我的标签式导航在 IE 中完全工作,这意味着看不到很多内容。

有人知道我的问题的解决方案吗?

这是我的 JavaScript 代码:

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

【问题讨论】:

  • 通过将代码块缩进 4 个空格,您可以在不使用反引号的情况下对其全部进行格式化。
  • 哦,甜心.. 不知道 :) 谢谢。
  • 编辑栏上的 {} 按钮晃动,顺便说一句。

标签: javascript pushstate


【解决方案1】:

试试jQuery BBQ: Back Button & Query Library。我使用它取得了巨大的成功。

【讨论】:

    猜你喜欢
    • 2023-03-26
    • 2012-02-07
    • 2014-07-24
    • 2012-12-18
    • 2012-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-15
    相关资源
    最近更新 更多