Tony Peterson
Tony Peterson

Reputation: 21202

window.focus doesn't work in IE

In Firefox 3, when I open a new window (or tab), using window.open, the new window has focus, which is what I want.

In IE, the old window still has focus for some reason, so I have researched the problem my window.open code does this now.

  var w = window.open("Sheet.aspx", "_blank");
  w.focus();

Unfortunately, this isn't working for me in IE 7. The old window still has focus. What I am missing here?

I have IE set to open new pages in a tab, rather than a new page, and I've allowed popups for the domain my site is on.

I can see the IE progress indicator going on the second tab, but it never switches over to it.

Upvotes: 2

Views: 4710

Answers (1)

robertc
robertc

Reputation: 75777

I have almost exactly the same code in one of my web apps which works just fine in IE7. Does it work if you disable the pop-up blocker? Do you have any extensions/toolbars installed which do pop-up blocking, and can you try disabling them?

--edit:

My code is different to yours as it supplies a width and a height for the window so it opens as a pop-up, but if I set IE to 'Always open pop-ups in a new tab' it still focusses on the window for me but I have pop-up blocker completely turned off. I still think the most likely source of your problem is either the pop-up blocker or an add-on.

Upvotes: 1

Related Questions