Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setTimeout in IE 11 is not working properly

I am using the setTimeout function to set the focus on a button element of a bootstrap modal. The following is the small piece of code which I wrote:

let element = this.el.nativeElement;
setTimeout(() => element.focus(), 200);

This works correctly on Firefox and Chrome. But on IE 11, I get the focus on the button for a blink of a second and it looses focus.

Do I have to do anything different in the case of IE 11 here? Am I doing something wrong?

Any help would be really appreciated.

Thank you.

Cheers.

like image 557
ShellZero Avatar asked Sep 27 '16 18:09

ShellZero


1 Answers

IE11 doesn't support arrow functions. You will need to pass a function reference instead:

setTimeout(function (){ element.focus(); }, 200);
like image 172
Dan Def Avatar answered Oct 23 '22 13:10

Dan Def