|
|
|
When working with popup windows, three different techniques are relevant:
- HOW TO OPEN A WINDOW
- HOW TO CLOSE A WINDOW
- HOW TO CUSTOMIZE A WINDOW
This page covers these techniques one by one.
OPEN WINDOW
The basic javascript to open a new window is:
MyNewWindow=
window.open("http://www.mydomain.com/myfile.html", "NameOfMyWindow");
|
|
This will open a new window similar to the one described on the previous page.
We still haven't set any conditions for the size of the window or which of the browsers menus and buttons we want to be present.
CLOSE WINDOW
The javascript to close the window is:
NameOfMyWindow is the name you assigned to the window when you opened it.
Note:
If you want to close the current active window you do not need to specify the window name.
Instead you can simply use:
CUSTOMIZING A WINDOW
You can add several parameters for the new window.
This will allow you to control the size as well as which parts of the browser should be available in the window.
option | explanation
| toolbar = yes | no | add/remove browsers toolbar
| location = yes | no | add/remove browsers location field
| directories = yes | no | add/remove browsers directories field
| status = yes | no | add/remove browsers status field
| menubar = yes | no | add/remove browsers menubar
| scrollbars = yes | no | add/remove browsers scrollbars
| resizeable = yes | no | allow new window to be resizable
| width = value | window width in pixels
| height = value | window height in pixels
|
|
An example showing the way to define which parts of the browser should be visible is shown below:
PageURL="http://www.mydomain.com/myfile.html";
WindowName="MyPopUpWindow";
settings=
"toolbar=yes,location=yes,directories=yes,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width=600,height=300";
MyNewWindow=
window.open(PageURL,WindowName,settings);
|
|
Note:
There are no spaces between the settings.
If you add spaces here, the window will not open correctly in Netscape browsers.
|
|
|
|