【问题标题】:Accordion not working in IE8 but works in others, why?Accordion 在 IE8 中不工作,但在其他人中工作,为什么?
【发布时间】:2014-06-17 20:05:21
【问题描述】:

我正在处理一个手风琴内容页面,该页面将通过在 url 字符串的末尾添加锚类型编号来显示页面加载时打开的部分。如下所示: 网站/accordion_page.html#2

它在 Firefox 和 Chrome 中运行良好,但 Internet Explorer 8 没有显示任何手风琴功能。 我在这里包含了一个 jsfiddle:http://jsfiddle.net/w4v34/1/

或者也请看我下面的代码,谢谢你的帮助,Attila

$(document).ready(function() {

  var allPanels = $('.accordion > dd').hide();
  var allControlIcons = $('.accordion > span');

  var urlString = $(location).attr('hash').slice(1);
  var startN = (parseInt(urlString))-1; // minus one to make it zero based for the eq: numbering
  console.log(startN);

  $('.accordion dd:eq('+startN+')').addClass('active').show();
  $('.accordion dt:eq('+startN+')').find('span').
  empty().html('–');


  $('.accordion > dt > a').click(function() {
      $this = $(this);
      $target =  $this.parent().next();
      $control = $this.find('span');

      $('.accordion').find('span').empty().html('+');
      $this.closest('dt').find('span').empty().html('–');

      if(!$target.hasClass('active')){

         allPanels.removeClass('active').slideUp("fast");
         $target.addClass('active').slideDown("fast");

      } 

    return false;
  });
});

【问题讨论】:

    标签: javascript jquery internet-explorer-8 tabs accordion


    【解决方案1】:
    console.log(startN);  // this is where you get your error on IE8
    

    修复:

    if (!window.console){ console = {log: function() {}} }; // works perfectly on IE8,chrome and FF
    

    更新小提琴:

    点击ME

    参考:

    Here

    @OP 请在发布之前尝试搜索您的问题/错误。谢谢

    【讨论】:

    • 谢谢!我已经研究过与 IE8 错误相关的“手风琴”,但我没有想到实际上“控制台”正在为 IE8 制造问题。
    • 我建议您使用FireBug 进行调试
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    • 1970-01-01
    • 2010-12-12
    • 1970-01-01
    • 2010-10-24
    • 2012-07-14
    • 2012-12-17
    相关资源
    最近更新 更多