The windows on this page may overlap, so separate them. Press the browser's back button for this page and the windows will all go! Press the back button now and look for those little windows. I hope you can't find them! Then come back and look at the code.
First of all, we need to declare two variables, win1 and win2:
.We need to do this because the variables in the first function is not visible to the other function. So we declare it globally.
Next we write a function to open two windows in the HEAD of the document:
win1.document.write('This is window one');
win2.document.write('This is window two');
We activate this part of the script in the BODY tags by using:
When we close this page, we also close all the windows we have opened. We do this by writing a function in the HEAD:
/*This function closes all the windows when
the page closes*/
We close our windows by using the window.close() function. If we just say 'window.close()' then the Browser will get involved and ask us if we really want to close down. This function was put in this page's BODY: