Javascript error in Setting focus to a textbox inside a lightbox(Overlay) window.

Posted by Rishabh Ohri on Stack Overflow See other posts from Stack Overflow or by Rishabh Ohri
Published on 2010-06-09T09:23:59Z Indexed on 2010/06/09 11:42 UTC
Read the original article Hit count: 178

Filed under:
|
|

Hi All,

I have a textbox, a button and a "AdvancedSearch" link on my aspx page. On page load, the focus is set to the textbox. On click of the "AdvancedSearch" link, a lightbox(overlay) window will be opened. I want to set focus to a textbox present within this lightbox window. I am using javascript to achieve this. The code looks somewhat like this:

if( element.type != "hidden" && element.style.display != "none" && !element.disabled ) {
element.focus();
return;
}

when the lightbox window loads, i get a javascript error - "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus"

Any idea why this error is thrown and why it is not able to set focus to the textbox in the lightbox window?

Thanks, Rishab.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET