0

I am working on an accordion content page which will show a section open on page load by adding anchor type number to the end of the url string. Such as the following: site/accordion_page.html#2

It works well in Firefox and Chrome but Internet Explorer 8 is not showing any of the accordion functionality. I have included a jsfiddle here: http://jsfiddle.net/w4v34/1/

Or please see my code below as well, thank you for assistance, 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;
  });
});
reinhat
  • 147
  • 3
  • 10

1 Answers1

0
console.log(startN);  // this is where you get your error on IE8

Fix :

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

Updated Fiddle :

Click ME

Reference :

Here

@OP pls try to search your problems/bugs before posting. thanks

Community
  • 1
  • 1
Yaje
  • 2,753
  • 18
  • 32
  • Thank you! I have already researched "accordion" related to IE8 bugs but I haven't given any thoughts that actually the "console" was creating the hiccup for IE8. – reinhat Jun 18 '14 at 14:19
  • i recommend that you use [FireBug](https://getfirebug.com/) for debugging purposes – Yaje Jun 18 '14 at 23:37