IE7 window.open when .focus returns null

I'm trying to do something like this

win = null;
win = window.open('/url/to/link','tab');
win.focus();

but in IE7 it returns me in the string win.focus (); an error that will be zero.

How can I solve it?

Thanks in advance!

+1
source share
3 answers

You can try adding a little delay to make sure the window is open.

//win = null;  <--useless
win = window.open('/url/to/link','tab');
if(win)window.focus();
else{
    var timer = window.setTimeout( function(){ if(win)win.focus(); }, 100 );
}

On this day, most people avoid pop-ups and use modal layers.

+1
source

Blockquote <Return Value

Returns a link to a new window object. Use this link to access properties and methods in a new window.

Internet Explorer 7 Windows Vista: ( Internet Explorer) null. , Internet Explorer . Internet Explorer, . . . Internet Explorer. , WebBrowser. > Window.Open

+2

, :

myWin = window.open(etc)

//in the child window, call window.opener.myFocusFunction()
//in the parent window, use this...

function myFocusFunction(){
   myWin.focus();
   //myWin.blur();
   //uncomment as needed!
}

, .

0

All Articles