给IE8儿童窗口焦点 [英] Giving a child window focus in IE8

查看:163
本文介绍了给IE8儿童窗口焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从Javascript函数启动一个弹出窗口,并确保它使用以下调用进行焦点:

window.open (popupUrl,popupName,...)。focus();



它适用于所有其他浏览器,窗口在闪烁的橙色任务栏通知的背景。显然这是IE8的一个特性:

http://msdn.microsoft.com/zh-cn/library/ms536425(VS.85).aspx



它说我应该能够通过从新页面调用focus()调用来关注窗口,但是这似乎也不起作用。我已经尝试在页面中的脚本标记插入window.focus()和身体的onload,但它没有效果。有没有什么东西我失踪了在页面加载时调用focus()方法,或者另一种方式来启动IE8不会隐藏的弹出窗口?

解决方案

我找到了问题所在 - 原来在onload中运行window.focus()失败的原因是因为第一个window.open()。focus()调用导致它开始在后台闪烁,然后任何后续的焦点呼叫将无法正常工作。如果我不试图把它从调用窗口集中,但只从弹出窗口通常到达前面。多烦人的功能...

I'm trying to launch a popup window from a Javascript function and ensure it has focus using the following call:

window.open(popupUrl, popupName, "...").focus();

It works in every other browser, but IE8 leaves the new window in the background with the flashing orange taskbar notification. Apparently this is a feature of IE8:

http://msdn.microsoft.com/en-us/library/ms536425(VS.85).aspx

It says that I should be able to focus the window by making a focus() call originating from the new page, but that doesn't seem to work either. I've tried inserting window.focus() in script tags in the page and the body's onload but it has no effect. Is there something I'm missing about making a focus() call as the page loads, or another way to launch a popup that IE8 won't hide?

解决方案

I figured out what the issue was - turns out the reason running window.focus() in the onload wasn't working was because the first window.open().focus() call caused it to start flashing in the background, and after that any subsequent focus calls wouldn't work. If I don't try to focus it from the calling window but only from the popup it comes to the front normally. What an annoying "feature"...

这篇关于给IE8儿童窗口焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆