我有一个相当复杂的网络应用程序,我已将其压缩为以下两个 HTML 页面,但问题仍然存在。问题?在 IE(8 和 9)中,厚盒模式(iframe)的输入字段在一秒(或更短时间)后失去焦点。它仅在模态中发生。如果您自行加载页面,焦点不会丢失。
我尝试过 jQuery 1.4.2 和 1.7.2,每个版本都会出现问题。我将其设置为 jsfiddle 但不认为它支持触发第二页。已设置好以便您可以看到它在这里工作 http://home.comcast.net/~filehost/gen/test.html
基页:
<!DOCTYPE HTML>
<html>
<head>
<link href="http://jquery.com/demo/thickbox/thickbox-code/thickbox.css" media="screen" rel="stylesheet" type="text/css" >
</head>
<body>
<a id="createAccountLink" class="thickbox" href="test2.html?KeepThis=true&TB_iframe=true&height=400&width=600">Login</a>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://jquery.com/demo/thickbox/thickbox-code/thickbox.js"></script>
</body>
</html>
Modal:
<html>
<head>
</head>
<body>
<input type="text" id="ContactFormName" name="firstName" class="text" value="" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$("#ContactFormName").focus();
</script>
</body>
</html>
如果我从头开始构建这个,我不会使用thickbox。但现在改变它并不是一个真正的选择,因为它在其他地方被大量使用。
Answer注意力必须被推迟。即使 1 毫秒也有效。
setTimeout (function () {
$("#ContactFormName").focus();
}, 1);
注意力必须被推迟。即使 1 毫秒也有效。
setTimeout (function () {
$("#ContactFormName").focus();
}, 1);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)