Entry
if we open multiple popup windows,how to set the focus
Sep 3rd, 2007 12:53
Dave Clark, raj bloggs,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Raj,
First, define for yourself some global variable to hold a pointer
to the popup windows you will be generating:
var ptr1 = null;
var ptr2 = null;
var ptr3 = null;
Then, in one or more functions you can generate your popup
windows and save a pointer to that window:
ptr1 = window.open(...);
ptr2 = window.open(...);
ptr3 = window.open(...);
Lastly, you can have other events which will determine upon which
window to focus:
if (ptr1 && !ptr1.closed) ptr1.focus();
if (ptr2 && !ptr2.closed) ptr2.focus();
if (ptr3 && !ptr3.closed) ptr3.focus();
Note that these same pointer variables can be used to reference
the document inside of that particular window. The following is an
example which would reference the value of a text box within a form in
a popup window -- providing the correct indices are supplied to the
collections shown:
var ele = ptr1.document.forms[x].elements[x];
alert('Field "'+ ele.name +'" has a value of "'+ ele.value +'".');
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~