KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This may be the most obscure bug I have yet encountered in many years of working with JavaScript and any version of Internet Explorer. We're using YUI 2.7 for some of the (non)convenience methods. Sigh, what I would do for jQuery.... This is affecting Internet Explorer 6 and Internet Explorer7. Internet Explorer 8 behaves properly. All other browsers also behave properly. Problem: When I set focus on a particular element, I get the following error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept focus. So I have a div called 'add-comment-login-overlay' that contains the input element. This div is display:none until the user clicks one of several links called 'login'. The following is the JavaScript code I'm using that selects the 'login' links, which moves the position of the 'add-comment-login-overlay' in the DOM, sets display:block, then sets focus on the 1st input field in the overlay. It's this process of setting focus that is causing the error I wrote above. //Get Login links in comment forms. links = YAHOO.util.Dom.getElementsByClassName('addCommentLoginLink'); //Set click event for login links. YAHOO.util.Event.addListener(links, "click", function(el){ //Stop link. YAHOO.util.Event.preventDefault(el); //Move login overlay in DOM. if( el.srcElement ){ var target = el.srcElement; }else{ var target = el.currentTarget; } YAHOO.util.Dom.insertAfter( overlay, target.parentNode.parentNode.parentNode.parentNode ); //Set to visible. YAHOO.util.Dom.setStyle( overlay,'display', 'block' ); //Set focus to username field. document.getElementById('add-comment-login-overlay-username-input').focus(); }); I can absolutely confirm that the overlay div is completely visible. I can look at it. I have added a setInterval timer to measure what's happening and it has no
Tags (comma-separated)
Save Edits
Cancel