Using Window Options


window.open("http://www.samspublishing.com/",   "samsWindow",   "width=640,height=480,directories=no,menubar=no, toolbar=no,scrollbars=yes"); 

The third parameter of window.open() is a list of comma-separated values that define how the new window looks. You can define the size (as long as both width and height are at least 100 pixels), toggle some window features like the status bar, and more. Table 9.1 shows the most important options (however, the list is not complete, leaving out several browser-dependent options).

Table 9.1. Window Options

Option

Description

dependent

Closes the new window if the parent window is closed

directories

Toggles the personal toolbar

height

Height of the window

innerHeight

Height of the window excluding the window decoration (non-IE only)

innerWidth

Width of the window excluding the window decoration (non-IE only)

left

Horizontal position of the window (IE only)

location

Toggles the location bar

menubar

Toggles the menu bar

outerHeight

Height of the window (non-IE only)

outerWidth

Width of the window (non-IE only)

resizeable

Whether the window may be resized by the user

screenX

Horizontal position of the window (non-IE only)

screenY

Vertical position of the window (non-IE only)

scrollbars

Toggles the scrollbars

status

Toggles the status bar

toolbar

Toggles the toolbar

top

Vertical position of the window (IE only)

width

Width of the window

z-lock

Gives the window a lower z-lock (position on the z axis) value


The preceding code uses some of these options. Some take numeric values; some require yes or no as their values. Take care that you do not use spaces between options.

Warning

You cannot expect all of these effects to work on all browsers in an identical fashion. For instance, the Opera browser opens a new window not in a new browser window, but (depending on the browser version) in a new tab, which of course has the default window decoration and the default window size.


Figure 9.1 shows how the newly opened window (file openoptions.html) looks with the given options.

Figure 9.1. The new window has only very little decoration.





JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net