Question

My script:

var slidespeed = 200;
$('.noti_user a').off().on('click',function(){
    if($(this).hasClass('active')){
        $(this).removeClass('active');
        $('.sub_menu_closer').hide();
        $('.noti_drop_down').slideUp(slidespeed);
    }else{
        $('.left_user_inner').children('div').children('a').removeClass('active');
        $('.left_logo_part a').removeClass('active')
        $('.help_drop_down,.mail_drop_down').slideUp(slidespeed)
        $('.logo_drop_down').slideUp(slidespeed);
        $('.noti_drop_down').slideDown(slidespeed,function(){
            sScroll.refresh(); // here is error show
        });
        $('.sub_menu_closer').show();
        $(this).addClass('active');
    }
})

var sScroll; // here iscroll call
   sScroll = new IScroll('.noti_outer', {scrollbars: 'custom',mouseWheel: true});
   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

sScroll.refresh(); here is i refresh iScroll plugin

when i testing in ie8 browser this show error : Unable to get property 'refresh' of undefined or null reference

Was it helpful?

Solution

As mentioned above. The IScroll lib is not compatible with older IE versions. Therefore you can't call a method. To prevent the error, you can go like this:

  $('.noti_drop_down').slideDown(slidespeed,function(){
    if (sScroll && typeof sScroll === 'object' && typeof sScroll.refresh === 'function') {
     sScroll.refresh(); // here is error show
    }
  });

This might be to many conditions in the if statement, simply check what sScroll is in IE, if it is undefined, reduce the conditions, but it should avoid the error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top