Thursday, March 6th, 2008 at 3:29 pm Filed under: Javascript Tags:

So like me you spent 30 minutes trying to fix this Internet Explorer JavaScript error ?

Cant move focus to the control because its invisible , not enabled, or a type that does not accept the focus.

In that case don’t waste time trying to understand it, odds are you have conflicting ids in your document. Also, remember IE 7 and the previous versions are alone to think a name attribute should be treated like an id.

If that’s not it, then it’s because your html object is not considered active and visible on the page. It could be because the innerHTML is not done inserting, because the browser has not refreshed the DOM or because Orion is in Sagittarius’ house, but you have to find a way to slow your code’s execution.

Comments RSS

You can leave a response, or trackback from your own site. 3 Responses to “Can’t move focus to control?”.

Arthy

I have trying to debug this problem but nothing seems to work. Luckily i came across your site. But now I am wondering how to slow down my code!

Can you please suggest a way to slow down the code’s execution in Javscript?

Arthy

I found this method in the net: setTimeout(“elm.focus()”,1250);
But even after increasing the time to 5 seconds, it did not work.

I have ensured that there is no conflicting ids. And my element is visible and not disabled. But still I get this error. Any idea what else could be wrong?

Your help will be greatly appreciated!
Thanks for your time.

francoisfaubert

Is the page already loaded when that happens (say, the code launches on a mouse click) or does the browser hit the Javascript line when you enter the page? If it’s while loading the page, you can tie it with the body’s onload event (or preferably DOMEvent) either manually or with a javascript library.

It’s not the prettiest method for listening to an event, but try something like this:

<body onload="your_func_that_sets_focus();"> // Shouldn't need a timeout

If that doesn’t help, I’d like to see your code if you can send a link to the page online.

Leave a Reply