Controlling the browser window through Javascript

I have a web application that launches a url in other windows / tabs. I would like to check if a window / tab exists; if not, I want to create it yet, I would like to select it in the first position. I use:

wf=window.open(address, web_form_target, 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=450');
if(wf!=null)
    wf.focus();

But this only happens for the first time (in IE, not in Firefox); if I create a new tab in the window when I call window.open (), nothing happens; if I close the window, it recreates it, but saves it in the icon ... Is there a way I can follow to get a good result?

Thanks in advance. Greetings, p.

+5
source share
2 answers

, , , . , oWindow , open , . , , ... , :

var oWindow;

function openWindow(p_strURL) {

    if(!oWindow || oWindow.closed) {
        oWindow = window.open(p_strURL, "oWindow", "status, scrollbars, resizable, width=800, height=500");
        if(!oWindow.opener) {
            oWindow.opener    = window;
        }
    }
    else {
        oWindow.location.href = p_strURL;
        oWindow.focus();
    }
}

, ,

+2

web_form_target - .

if (wf.name !==  web_form_target) {
   // create it
}
0

All Articles