IE9 Window Loses Focus due to jQuery Mobile

前端 未结 4 2271
深忆病人
深忆病人 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();
    }
    

提交回复
热议问题