Autofocus not working in ie11

when i put one div tag then i set autofocus on that div after that when i press the button then focus not going on that div.in mozilla and chrom all are  working fine
bharath kuamr ReddyDOT NET DEVELOPERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
try giving it a tabindex attribute:
<div tabindex="-1">...</div>

Open in new window


Also, if you are calling focus() dynamically, try calling it from within a setTimeout() -ex:
setTimeout( function(){  element.focus(); },10);

Open in new window


where element is a node reference to the div in question
1
bharath kuamr ReddyDOT NET DEVELOPERAuthor Commented:
Not working  in IE
0
Dave BaldwinFixer of ProblemsCommented:
Show us some code that demonstrates the problem.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bharath kuamr ReddyDOT NET DEVELOPERAuthor Commented:
when i put one div tag then i set autofocus on that div after that when i press the button then focus not going on that div.in mozilla and chrom all are  working fine

MyCode
--------------------------------------------------------------------------------------------------
<div id="error_msg" class="error_text margin_px"></div>

in my Js file
----------------------------------------------------------------------------------------------------
   var element = document.getElementById("error_msg");
                setTimeout(function () { element.focus(); }, 10);
----------------------------------------------------------------------------------------------

The above code not working in IE when i click button focus is not going to that div
0
Dave BaldwinFixer of ProblemsCommented:
That's really not enough.  I can't make a test page out of that that will do anything in Firefox.  With just that, you can't even tell if the 'focus' has moved to the 'div'.
0
bharath kuamr ReddyDOT NET DEVELOPERAuthor Commented:
Then Please let me know How can i do that one.I am getting this last issue last two days.
0
Dave BaldwinFixer of ProblemsCommented:
0
hieloCommented:
Try:
var element = document.getElementById("error_msg");
element.setAttribute('tabindex',-1);
setTimeout(function () { element.focus(); }, 100);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.