document.getElementById("username").focus();
此js在IE中可用,但在firefox中失效;
[color=red]解决方法:[/color]
加定时器
[size=medium]window.setTimeout(function(){document.getElementById("username").focus();}, 0);[/size]
此js在IE中可用,但在firefox中失效;
[color=red]解决方法:[/color]
加定时器
[size=medium]window.setTimeout(function(){document.getElementById("username").focus();}, 0);[/size]
本文探讨了在JavaScript中使用getElementById方法聚焦元素时,在IE与Firefox浏览器之间的兼容性问题,并提供了通过添加window.setTimeout函数来解决该问题的方法。
364

被折叠的 条评论
为什么被折叠?



