I am having a web page which contain four links, each link open a popup window. I am using a common JavaScript function to open popup window, as given below
I think what you want for 1 and 2 is:
if(!targetWin)
{
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no,
directories=no, status=no, menubar=no, scrollbars=Yes, resizable=no,
copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
targetWin.focus();
For 1 and 2 , you can use this function
// loads an URL into the popup without reloading it
function popupnr(mylink, windowname, refocus) {
// open the window with blank url
var mywin = window.open('', windowname, 'window attrs here');
// if we just opened the window
if (mywin.closed || (!mywin.document.URL) || (mywin.document.URL.indexOf("about") == 0)) {
mywin.location = mylink;
}
else if (refocus) {
mywin.focus();
}
// return the window
return mywin;
}
You cant refer a child window by its name. There is no window.children. You need to call window.open
to get a reference.
Yes you can. But u need to use the same window name while calling window.open