IE9 Window Loses Focus due to jQuery Mobile

前端 未结 4 2185
深忆病人
深忆病人 2021-02-19 20:20

In our product, we\'re using the most recent development version of jQuery Mobile in our ASP.NET website. Each and every time we do an ASP.NET postback, the browser window goes

相关标签:
4条回答
  • 2021-02-19 20:44

    I know this is an old post, but for people coming here from Google:

    I ran into this same issue today. It seems this lose focus behavior is what IE does when you trigger the blur event on the window object. This was the code that caused this issue for me:

    $(document.activeElement).blur();
    

    activeElement will default to the body element when there are no other elements in focus, and the blur event then bubbles up to the window. To fix this I simply did a check like:

    if (document.activeElement != $('body')[0]) {
        $(document.activeElement).blur();
    }
    
    0 讨论(0)
  • 2021-02-19 20:44

    I had similar problem with IE10 and jQuery 1.7.2. I found these lines in my code:

    $(document.activeElement).blur();
    

    and

    $(':focus').blur();
    

    So, adding simple .not('body') resolves the problem:

    $(document.activeElement).not('body').blur();
    $(':focus').not('body').blur();
    
    0 讨论(0)
  • 2021-02-19 20:45

    This same issue seems to occur with jQuery Mobile 1.4.2.

    When using IE 10, with a single tab open and another window on the same monitor, if you open a popup it will send the browser to the background.

    To fix this you have to edit the _handleDocumentFocusIn function. You need to change the line(10391) that reads:

    target.blur();

    to

    if (targetElement.nodeName.toLowerCase() !== "body")
    {
        target.blur();
    }
    

    I made a pull request so hopefully this will be included in the next version.

    0 讨论(0)
  • Just posting this link to anybody who is experiencing more of this continued mess. I am seeing the problem on IE 9 and IE 10 on a window.location = 'BLAH', from within the Angular location resource.

    This doesn't seem to solve the problem for me, but it may help others:

    http://support.microsoft.com/kb/2600156/en-us

    0 讨论(0)
提交回复
热议问题