Pergunta

I am using below code for iPad. But though an error message in IE 'Object not supported (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);
Foi útil?

Solução

The error is because addEventListener is supported only in IE9+, either you need to use attachEvent() or since you have jQuery use it

$(document).on('touchstart', function (e) {
    if (!isTextInput(e.target) && isTextInput(document.activeElement)) {
        //document.activeElement.blur();
        $('input').blur();
    }
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top