Hi,
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 at the line of win.focus(); the error that win is null.
How can I solve it?
Thanks in advance!
Hi,
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 at the line of win.focus(); the error that win is null.
How can I solve it?
Thanks in advance!
Blockquote < Return Value
Returns a reference to the new window object. Use this reference to access properties and methods on the new window.
Internet Explorer 7 on Windows Vista: Opening a new window from an application (other than the Internet Explorer process) may result in a null return value. This restriction occurs because Internet Explorer runs in protected mode by default. One facet of protected mode prevents applications from having priveledged access to Internet Explorer when that access spans process boundaries. Opening a new window by using this method generates a new process. For more information about protected mode, see Understanding and Working in Protected Mode Internet Explorer. This commonly occurs for applications that host the WebBrowser control.> Window.Open method documentation
You can try adding a slight delay to make sure that 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 );
}
This day in age, most people avoid pop up windows and use modal layers.