我在 iPad 上使用以下代码。但尽管 IE 中出现错误消息“不支持对象(addEventListener)”
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);
最佳答案
错误是因为addEventListener仅在 IE9+ 中受支持,您需要使用 attachEvent()或者因为你有 jQuery 使用它
$(document).on('touchstart', function (e) {
if (!isTextInput(e.target) && isTextInput(document.activeElement)) {
//document.activeElement.blur();
$('input').blur();
}
});
关于javascript - 通过 Internet Explorer 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23510810/