2014-05-07 48 views
0

我正在使用iPad的以下代碼。但是,儘管在IE瀏覽器的錯誤信息「對象(不支持的addEventListener)」通過Internet Explorer中的錯誤

function isTextInput(node) { 
    return ['INPUT', 'TEXTAREA'].indexOf(node.nodeName) !== -1; 
} 
document.addEventListener('touchstart', function(e) { 
    if (!isTextInput(e.target) && isTextInput(document.activeElement)) { 
    //document.activeElement.blur(); 
    $('input').blur(); 
} 
}, false); 
+1

提示:__attachEvent__,http://www.javascripter.net/faq/addeventlistenerattachevent.htm – Satpal

+1

謝謝Satpal。這是有幫助的\ –

回答

3

這個錯誤是因爲addEventListenerIE9+僅支持,則需要使用attachEvent()或因爲你有jQuery的使用

$(document).on('touchstart', function (e) { 
    if (!isTextInput(e.target) && isTextInput(document.activeElement)) { 
     //document.activeElement.blur(); 
     $('input').blur(); 
    } 
}); 
+1

謝謝阿倫。這對我有效 –