自从升级到最新版的Chrome 34.0.1847.116后,调用时焦点事件似乎没有触发。
myinput.focus()
在JavaScript中。
在Chrome 33.0.1750.154中运行正常。
test.html
<html>
<head><title>Test</title></head>
<body>
<input id="test_box" onfocus="alert('focused');" />
</body>
</html>
从控制台:
document.getElementById('test_box').focus();
Chrome 34没有弹出警告。
有什么想法?这是个bug吗?有没有方法来触发事件?
alert
,因为alert
会影响焦点。在Windows上使用Chrome 34.0.1847.116进行测试,我看到了即将聚焦的消息和onfocus
属性的消息。 - T.J. Crowder