faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 4 people (25%) answered Yes
Recently 1 of 4 people (25%) answered Yes

Entry

array of child windows

Apr 8th, 2008 18:50
ha mo, Dave Clark, Prateek Gandhi,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Prateek,
     You can arrange an array of child windows as follows:
var child_windows = new Array(
    new Array(null, 'url1', 'window_name1', '...window features...'),
    new Array(null, 'url2', 'window_name2', '...window features...'),
    new Array(null, 'url3', 'window_name3', '...window features...'),
 ...
    new Array(null, 'urln', 'window_namen', '...window features...')
); // no comma after last entry above
     Then, you could have a function to manage opening the child 
windows:
function open_child(n)
{
    if (n > child_windows.length) return false;
    if(!child_windows[n-1][0]
    ||  child_windows[n-1][0].closed)
        child_windows[n-1][0] = window.open(child_windows[n-1][1],
                                            child_windows[n-1][2],
                                            child_windows[n-1][3]
                                            );
    return true;
}
     and you could have a function to manage refreshing the child 
windows:
function refresh_child(n)
{
    if (n > child_windows.length) return false;
    if(!child_windows[n-1][0]
    ||  child_windows[n-1][0].closed)
        child_windows[n-1][0] = window.open(child_windows[n-1][1],
                                            child_windows[n-1][2],
                                            child_windows[n-1][3]
                                            );
    else
        child_windows[n-1][0].location.reload(true);
    return true;
}
     and you could have a function to manage closing the child windows:
function close_child(n)
{
    if (n > child_windows.length) return false;
    if (child_windows[n-1][0]
    && !child_windows[n-1][0].closed)
        child_windows[n-1][0].close();
    return true;
}
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com