Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 373837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:20:49+00:00 2026-05-12T14:20:49+00:00

This may be the most obscure bug I have yet encountered in many years

  • 0

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 effect. At one point I had 10 seconds going between the time the overlay was visible and when focus() was called and the error still occurs. Other than the error, the form is completely functional other than this error.

This is a simplified version of the overlay HTML code as a reference.

<div id="add-comment-login-overlay" class="add-comment-login-overlay" style="display: block;">
    <div class="add-comment-login-overlay-content clearfix">
        <div class="add-comment-login-overlay-signin clearfix">
            <input type="text" tabindex="2001" id="add-comment-login-overlay-username-input"/>
            <input type="password" tabindex="2002" id="add-comment-login-overlay-password-input"/>
        </div>
    </div>
</div>
  • 1 1 Answer
  • 4 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:20:49+00:00Added an answer on May 12, 2026 at 2:20 pm

    This is an old as heck bug in IE (glad to know it’s fixed in 8). I don’t know the official cause, but I believe it has to do with IE not repainting the DOM until after the execution context is complete, meanwhile trying to focus() the element while it thinks it’s still hidden:

    function calledAtSomePoint() { // begin execution
    
        // ...
    
        element.style.display = ''; // show container
        input.focus(); // IE thinks element is hidden 
    
        // end of execution, IE repaints the DOM but it's too late
    } 
    

    The solution is to use setTimeout:

    setTimeout(function() {
        document.getElementById('add-comment-login-overlay-username-input').focus()
    }, 0)
    

    I’ve had it happen many-a-time, including with jQuery. It’s no fault of any library. The setTimeout has always worked around it for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this may have been asked already but I cant really find it (most likely
This may be the most bizarre error I've ever encountered using .NET/C# - adding
This may be my most stupid question yet: I've implemented this tutorial on my
this may look as a duplicate, but I think I have tried most of
This may be a simple question for most Perl programmers, I have only used
This may be an unusual question, but are there any resources people have come
This may be for most languages in general, but I'm not sure. I'm a
Well, I'm learning Scala so this question may be too basic for most people.
This may be a stupid question but I have a code with the following
This may be have a better name than custom tab completion, but here's the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.