internet-explorer - IE8 : error on focus(): Can't move focus to the control because it is invisible

标签 internet-explorer

任何人都可以帮助我解决 IE 8 中的以下错误 错误详情如下:

网页错误详情

用户代理:Mozilla/4.0(兼容;MSIE 8.0;Windows NT 6.1;WOW64;Trident/4.0;SLCC2;.NET CLR 2.0.50727;.NET CLR 3.5.30729;.NET CLR 3.0.30729;媒体中心PC 6.0;CMDTDF;BRI/1) 时间戳:2013 年 4 月 9 日星期二 12:25:37 UTC

消息:无法将焦点移至控件,因为它不可见、未启用或属于不接受焦点的类型。 线路:1013 字符:5 代码:0 URI:/views/js/online.js

最佳答案

这是一个合理的错误。

判断一个元素在 HTML 页面上是否可见是非常困难的。您基本上必须向上遍历 DOM 树,检查元素或任何父元素是否具有“display:none”的 css 属性。

你可以用一个

包裹调用代码
try { 
  element.focus(); 
} 
catch (ex) { }

或者如果你正在使用类似 jQuery 的东西

if ($element.is(':visible')) {
   $element.focus();
}

关于internet-explorer - IE8 : error on focus(): Can't move focus to the control because it is invisible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15901933/

相关文章:

internet-explorer - Visual Studio 因 TypeScriptDebugEngine System.IndexOutOfRangeException 而崩溃

internet-explorer - 防止在 Internet Explorer 8 中缓存页面

javascript - 这个 comment/*@cc_on!@*/0 在 javascript 的 if 语句中做什么?

javascript - MSIE 如何发出警报 'unknow'?

java - 如何在 IE 中打开 wsdl 文件

javascript - jQuery 计数器函数在 IE < 8 中不起作用

javascript - .load 导致 Internet Explorer 中的总页面刷新?

html - IE和Chrome显示内层div的区别

.htaccess - 如何阻止 IE 中这种奇怪的自动重新加载

html - 悬停时显示 IE7 错误 : CSS background hidden,