autofocus attribute on input field not working in

2019-06-22 07:14发布

问题:

I can't seem to get this working in IE 11, I've created an extremely simple jsfiddle: http://jsfiddle.net/0qwbr7gh/ With the following input box:

<input type="text" autofocus/>

In chrome it works as expected, the input field has focus on load. In IE 11 it doesn't.

Microsoft say it's supported on their website along with an example. And also it says it's supported on: http://caniuse.com/#feat=autofocus

What have I missed?

回答1:

IE11 doesn`t support autofocus (despite is in caniuse). You can check How to make input autofocus in internet explorer?



回答2:

Well it's 2019, and IE11 is still bad at supporting autofocus. I was using AngularJS and the only thing that worked was this:

https://myplanet.github.io/angular-auto-focus/