Popup Windows6. Reusing the Popup Window |
|
Join the DiscussionMore of this FeatureBasic Popup Windows Generated Popups Popup or Popunder Timed Window Close Positioning the Window There may be times when you want to place multiple links on your site that are all intended to open a popup window but displaying different content in that popup window. Rather than annoy your visitors more than necessary by creating separate popup windows for each of these (and potentially ending up with lots of windows on their screen) we can reuse the existing popup window when they click on a second (and subsequent links) that are set to open a popup window. As you will remember from the first two tutorials we can either create a popup that will load a separately defined page (like this):
window.open('mywin.htm','name','height=255,width=250,
or alternatively we can generate the page content from Javascript (in which case the open statement looks like this):
TheNewWin = window.open('','name','height=255,width=250,
In each of these you will notice that the second parameter is shown in bold. This parameter is the one that gives the new window a name. If an open statement is run that is supposed to open a window where there is already a window open that has that name then instead of opening a new window the existing window will be used. You don't have to call your popup window name as I have in the above examples, you can call it whatever you want. If you have two or more links that open windows where you have supplied the same name then the existing popup window opened by the first link will be used if it is still open when they select the second link. If this happens then all of the subsequent parameters regarding the size of the window and which toolbars etc. to be displayed will be ignored and the existing size and setup will be used. |

