Link to home
Start Free TrialLog in
Avatar of bharath kuamr Reddy
bharath kuamr Reddy

asked on

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
Avatar of hielo
hielo
Flag of Wallis and Futuna image

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
Avatar of bharath kuamr Reddy
bharath kuamr Reddy

ASKER

Not working  in IE
Show us some code that demonstrates the problem.
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
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'.
Then Please let me know How can i do that one.I am getting this last issue last two days.
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial