I have a project with a main window that keeps references to windows that open on the site. All window.open() calls go through this main window.On IE7 and FF I've been able to use the window.focus() function to give focus to whichever window I wanted, using the stored references. In IE8 it doesn't appear to work at all.I made this very simple example: 2 links, one opens a new window called FocusExample_Window2.html and gives it focus - you then manually focus back on the main page and click the second link which gives focus to the window you just opened. You see the window flash yellow in the taskbar but it doesn't give focus.
Check your IE8 tabbed browsing settings....
When a popup is encoutered..... open in a new window
ensure that your web site domain is included in the IE8 popup white list or that your site is in the Trusted Sites zone where the popup blocker is disabled by default.
I have popup blocking disabled and have set it to Trusted Sites zone, and popups open in a new window, still having the same issue.This happens in IE8 normal mode and compatibility mode. On IE7 and other browsers this works fine.I can simply open a popup window and then on the new window, have a button with onclick="window.opener.focus(); return false;" and it will simply stay on the popup window. It's as if IE8 completely ignores window focusing.
- Edited by Miek Abel Thursday, July 23, 2009 10:41 PM
I don't have an answer, but I may have something to add. I do something roughly similar to what you are doing. I open a new window, assign it to a reference, and then using that reference attempt to call .focus. Like this:
mainAppWindow = window.open(...); mainAppWindow.focus();When I do this, the newly opened page has strange errors like "Image is undefined" but if I take out the call to focus there are no errors on the newly opened page!
It seems that ie8's focus no longer brings child windows (such as those created with the open method) to the foreground.http://msdn.microsoft.com/ja-jp/library/ms536425(en-us,VS.85).aspxIs there any other way to do this? It's an important feature.
- Edited by hatzhang Tuesday, August 11, 2009 1:50 AM
I use this function to popup a new window. It works for all browsers (so far). Is all of it logical? No. But after hours of aggravation it seems to work.
the stuff below doesn't make sense. How can popped window be true
and false at the same time? Who knows but in ie, if you don't
do it this way, you get an error
if(!poppedWindow || poppedWindow.closed)
//if the window exists, replace it's current url with passed url, then focus window
For anyone struggling with this issue who comes across this thread, Microsoft have sorted out the problem with an update for IE8.
It describes how when you use window.focus(), all you will get is that window flash in the taskbar, but it will NOT be brought into the foreground unless you apply the update suggested:
- Proposed as answer by wibwab Wednesday, February 01, 2012 3:37 PM