2014-01-31 28 views
0

我的腳本:無法獲取未定義或空引用錯誤的特性「刷新」在IE8

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();這裏是我刷新iScroll插件

,當我在IE8瀏覽器本次車展錯誤測試:無法以獲得未定義或空引用的屬性「刷新」

+0

張貼您設置sScroll的行。這是缺少的。 –

+0

@ axel.michel添加了sScroll行 –

+0

您確定IScroll與ie8兼容嗎?據我所知,IScroll的誕生足以填補移動瀏覽器對溢出的支持:滾動並且不支持舊桌面瀏覽器。 –

回答

1

如上所述。 IScroll lib與舊的IE版本不兼容。因此你不能調用一個方法。爲了防止錯誤,你可以去這樣的:

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

這可能是許多條件的if語句,只需檢查什麼sScroll是在IE中,如果它是不確定的,降低了條件,但應避免錯誤。

+0

不抱歉,它不工作。 slideDown我的下拉列表不起作用,這種情況下,我的下拉列表停止工作 –

+0

在這種情況下,你必須把if條件放在slidedown方法中,看修改後的答案。 –

+0

它工作得很好,謝謝你的幫助 –

相關問題