Build a website with javascript games and other dynamic content

Step seven - open and close a window

Opening a closing a window can be done for example to create a remote control for your website but be aware that WebTV boxes are not able to display two open windows at the same time. Still it is very useful for many others.


If you click on the button the following script will execute and open a new window with another document. The button looks in HTML as follows

<input type="button"
onclick="opendoc('close.htm')"
value="open other document" >
Upon click on the button the following script open_doc is called.
<script>
function opendoc(doc_url) 
{
window.open(doc_url,"some_window_name","width=60,
height=40,history=no,status=no,toolbar=no,
scrollbars=yes,resizable=no");
}
<script>

the script opens the document specified in the passed on URL and opens it in a browser that has a window size of 60x40. There will be no history, no statusbar and no toolbar available. If the content does not fit in the viewable window you can scroll the document but you can not resize it to see everything on one glance. Naturally you can specify all this just as you want to, but please be careful that your content really fits into the viewable area if you set resizable and scrollbars to no. In that case you are unable to look at anything that is not in the current view.

the button in the document is defined to close the window by calling a methode that is predefined in the browser. It just calls window.close() on the click of the button.

<input type="button" onclick="window.close()" value="close" >
Next step
 

AK
Start

My Games

Get Games

Build Games
space
1 - simple javascripts
2 - change form values
3 - statusbar & mouse
4 - change images
5 - preload images
6 - change location
7 - open/close windows
8 - other sources

Feedback or Questions

about me

 
 

Copyright by Armin Kielack 1998 last modified: