IE中Can't move focus to the control because it is invisible, not enabled, or of a type 。。。的解决方案

我们通过IHTMLDocument获取到一个元素之后进行focus,如果这个元素不可见时,会报出上面的这个错误,网上的例子很少在http://www.webdeveloper.com/forum/showthread.php?t=103574中给出了一个解决方案。这个只是一个民间的方案吧,IE官方好像米有办法来获取到一个element是否能够focus。

if(element.style.visibility=="hidden" || element.style.display=="none" || element.disabled==true) {
//do something because it can't accept focus()
} else {
element.focus();
}
原文地址:https://www.cnblogs.com/kwliu/p/2102217.html