Greybox: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus
Solution 1
It's a well known issue on IE.
You can read about it here.
The solution is to use the setTimeout() function to delay the focus() execute time.
you need to replace your line:
document.getElementById("textfield").focus();
with the following:
setTimeout(function() { document.getElementById("textfield").focus(); }, 10);
Solution 2
Just posting a quick answer to this... had to solve this tonight. Used a setTimeout to call the focus function briefly after the greybox page displays.
A little jQuery used in my version since it was already in this project but you could just as easily use window.onload()
<script type="text/javascript">
$(document).ready(function() {
setTimeout ( "document.getElementById('AdminID').focus(); ", 500 );
});
</script>
Related videos on Youtube
Michael
Updated on April 30, 2022Comments
-
Michael almost 2 years
Possible Duplicate:
JavaScript: Visibility error in Internet Explorer when setting focus on an input elementI have a page that loads within a greybox. I set the focus with
document.getElementById("textfield").focus()
- this works fine when calling the page directly.But when loaded in a greybox, setting the focus on the onload() event returns:
Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus
Calling it later works fine.
Any ideas?
Thanks!
-
nsilva over 10 yearsThanks a lot, this was annoying the hell out of me, and was causing so many issues with IE8
-
Spiff over 9 yearsI've seen this error only in IE8 and older