The magic of opening windows
I covered opening new windows safely in
the post
Links, onclick and page accessibility. Now let’s look
more closely at the open method on the Window
object and go through its arguments and the new window’s initial settings.
What the method does open
Calling this method on a Window object or in its context
opens a new window or loads a new document into a window
that’s already open.
Method signature
window.open(String url,String název_okna,String inicializační_parametry,boolean historie)
Let’s look at the arguments one by one. I’ve given the argument names in Czech and included their types.
url
This argument gives the URL for the new window. If it’s omitted or
is an empty string, the window opens blank.
název_okna
The newly opened window is referenced by this symbolic name. The
name lets a script manipulate the window, or it can be used as the value
of the target attribute on a and form
elements, as explained below.
inicializační_parametry
The initial window settings let you open it with
specified features
such as height, width or vertical scrollbars. If you omit the argument, the window opens with all the standard features.
If you pass it with at least one feature specified, the window opens with only that feature. According to
the specification, a feature should take yes or no, though 1 and 0 also seem to work.
Separate the individual features with commas.
histroie
If you open the window with this argument set to
true, no new entry is added to the window history, or rather to the
History object.
There are several ways to use the new window. If we open it
without a document, either by omitting url or passing an empty string,
we can use the value of název_okna as the
target attribute of a elements. That directs the action of the form
or link into this window.
Initial window settings
channelMode
Specifies whether to display the window in channel mode (IE 6.0).
dependent
If it’s set to yes or 1, the new window is a dependent child of the current window. For example,
minimizing the parent window minimizes the child too.
(Gecko–Mozilla 1.0, Opera 7.0)
directories
Directory buttons such as “What’s New” and “What’s Cool” (IE 6.0).
fullscreen
Opens the window in full-screen mode (IE 6.0).
height
Height of the visible part of the document in pixels.
innerHeight
Height of the visible part of the document in pixels (Gecko–Mozilla 1.0).
innerWidth
Width of the visible part of the document in pixels (Gecko–Mozilla 1.0).
left
The window’s x coordinate in pixels. Opera measures it relative to the tab.
location
Displays the field for entering a URL, also called the address bar.
menubar
The menu bar with items such as File, Edit and View (Gecko–Mozilla 1.0, IE 6.0).
outerHeight
Total window height in pixels (Gecko–Mozilla 1.0).
outerWidth
Total window width in pixels (Gecko–Mozilla 1.0).
resizable (Gecko-Mozilla 1.0,IE 6.0)
If this feature is omitted or set to no,
the window has no resize handles at its edges.
(The user may still be able to resize the window, depending on the platform.)
screenX
The window’s x coordinate in pixels (Gecko–Mozilla 1.0).
screenY
The window’s y coordinate in pixels (Gecko–Mozilla 1.0).
scrollbars(IE 6.0)
The window’s horizontal or vertical scrollbar.
status
Shows the browser’s status bar (IE 6.0, Gecko–Mozilla 1.0).
toolbar
Browser toolbar with Back and Forward buttons (IE 6.0, Gecko–Mozilla 1.0).
top
The window’s y coordinate in pixels. Opera measures it relative to the tab.
width
Width of the visible part of the document in pixels.
Parentheses show which browsers support the feature. I tested Internet Explorer 6.0 SP1, Mozilla 1.0 and Opera 7.0.
If none are listed, the feature works in all those browsers. Browsers
based on Gecko, including Phoenix, Firebird, Netscape 6.0 and Netscape 7.0, will probably behave like Mozilla.
Related articles
Related CZ Podcast episodes
- #217 · Ivo Lukačovič
On Windy, JavaScript and building companies. · Czech audio
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio