【发布时间】:2009-05-04 21:45:25
【问题描述】:
我正在尝试使用
将焦点设置在文本输入元素上document.getElementById( 'id' ).focus()
这适用于 Firefox 3,但不适用于 Internet Explorer 8。
在 Internet Explorer 中将焦点设置在 HTML 元素上的正确方法是什么?
【问题讨论】:
标签: javascript internet-explorer
我正在尝试使用
将焦点设置在文本输入元素上document.getElementById( 'id' ).focus()
这适用于 Firefox 3,但不适用于 Internet Explorer 8。
在 Internet Explorer 中将焦点设置在 HTML 元素上的正确方法是什么?
【问题讨论】:
标签: javascript internet-explorer
您确定您的代码没有其他问题吗?我没有要测试的 IE8,但这个独立的示例在 IE7 中完美运行 - 也许您可以在 IE8 中尝试?
<html><body>
<form><input type='text' id='bim'></form>
<script>document.getElementById('bim').focus()</script>
</body></html>
【讨论】:
value='wagga' 证明它是有效的。 .focus() 将选择 Chrome 中的值,而不是 IE8 中的值。有什么建议吗?
.select() 将在 Chrome 和 IE8 中选择值,.focus() 将在两个浏览器中执行两种不同的操作。对不起。