开发者

When my page loads in IE, the window immediately jumps behind other windows

A user recently reported this mystifying bug: On one of my pages:

  • When it loads in IE (observed in IE8, it's status in other versions is unknown); and
  • At least one other window is open behind IE

The following happens:

  • The IE window moves behind all other windows; and
  • It keeps its focus. This means that the window's taskbar button is depressed and the page receives all expected key events, even while the window is completely hidden.
  • Trying to bring IE to the foreground is futile. It just immediately jumps back again as long as there's another window to hide behind.

I'm by no means an IE expert. I keep an XP virtual machine around for those rare开发者_如何学编程 occasions when I must use IE or Windows. So I'm unfamiliar with how to even begin tracking down this bug. Can someone help me out in pinpointing this bug?


I have had the same problem in the past - the body is being blurred [document.body.blur() only works in IE]. The function doing this is setBlur() in your source.

Current version:

function setBlur(items) {
    var item;
    for (var i = 0; i < items.length; i++) {
        item = items[i];
        if (item.id == "search-box-wrapper") continue;
        if (item.children) setBlur(item.children);
        try {
            item.onfocus = function() {
                this.blur();
            };
        } catch (e) {
            if (console) console.warn(e);
        }
    }
}

Version excluding body blurring (solving your problem hopefully):

function setBlur(items) {
    var item;
    for (var i = 0; i < items.length; i++) {
        item = items[i];
        if (item.id == "search-box-wrapper" || (item.tagName).toUpperCase() == "BODY") continue;
        if (item.children) setBlur(item.children);
        try {
            item.onfocus = function() {
                this.blur();
            };
        } catch (e) {
            if (console) console.warn(e);
        }
    }
}

This makes sure the function setBlur() cannot be used to blur the body by accident, although does not address the function which calls setBlur([document.body, ..., ...]).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜