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?

4 of 16 people (25%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

if we open multiple popup windows,how to set the focus

Apr 8th, 2008 18:31
ha mo, 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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