Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to handle window not by using global varible?

Status
Not open for further replies.

zhuzhengyu

Technical User
Jul 21, 2000
19
CN
question:<br>if we hope to handle a window ,there are methods:<br>1.use a global variable ,defect:if I close the window manually and not by procedure , so the variable becomes garbage<br>2.use &quot;self&quot;&quot;parant&quot;&quot;top&quot; &quot;opener&quot; ,but its use is limited<br><br>I hope to find all windows under conditions that I don't know everthing
 
Im a little confused, but here what you probably need to do. Use the onload and onunload event handlers to set flags when the windows are open. Have a global counter variable on the opener that you append to each window name so:<br><br>&quot;mywin&quot; + global_counter = window.open(...your stuff here)<br>now, when the window opens, have a variable (well call it opener_ref) in the window you open that matches in name the mywin&nbsp;&nbsp;+ global_counter. In the onunload handler of the opened window, set the mywin variable to false, before doing anything, always test if(mywin2){...}<br><br>If its just one window its much easier. Have one variable in the opener that tests a flag set when the window opens before doing any interwindow communication.<br><br>Hope I helped<br><br><A HREF="mailto:jared@aauser.com">jared@aauser.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top