If you completed the assignments in the previous session you know how to open new windows. Like the alert() method, the open() also takes arguments. When used without any arguments, the new window displayed is blank. Here I tell you how to embellish this new window.
This opens a new window with welcome.html page.
The open() method takes four arguments:
window.open('URL', 'NAME', 'FEATURES', 'REPLACE')
We have already seen that if we provide the URL of a document through the first argument, it will be loaded in the new window.
NAME: specifies a name for the new window that can then be used as value for the TARGET attribute of <A> tags.
FEATURES: let you define properties of the window such as width, height, presence or absence of scrollbars, location bar, stauts bar etc. The list of features is quite daunting so we shall go over them gradually.
REPLACE: takes a boolean value... we won't bother ourselves with this argument!
List of important features
- height: Specifies height of the window in pixels.
- width: width of the new window in pixels
- location: determines the presence of the location bar
- menubar: menubar
- scrollbars: scrollbars
- status: status bar
- toolbar: toolbar
- directories: specifies the display of link buttons
- resizable: determines whether the window can be resized. If it's absent or its value is set 'no', the window does not have resize handles around its border.
- fullscreen: Specific to the Internet Explorer, it determines whether the window is displayed in the full screen mode.
This opens a new window 300 pixels in width and 200 pixels in height. Pay close attention to how the features are written. The two features (width and height) are enclosed by a pair of quotes without any spaces and there are no quotes surrounding the values.
Did you notice something in the new window?
It didn't have any scrollbars, location bar, status bar, menubar, toolbar or buttons!
The width and the height take a number (pixels) as value, for other features the value is either a yes or no.
This window has the menu and the status bars. The others are absent since we didn't specify them.
But before that, here is a small novelty for Internet Explorer users.
The fullscreen feature is specific to this browser and displays the document on the entire screen. A neat effect... sort of! Click on the F11 to remove the full screen display.
- Write the code for opening a new window with a width of 400 pixels, height 200 pixels, scrollbars, menubars.
- If the method for opening windows is open(), what do you think will be the method for closing windows?
- What happens if you open a new window omitting the features argument?
Comments, questions, feedback... whatever!
Recent Blog Posts
- Hotmail Sign In page
- Create a Hotmail account - Instructions
- Create Gmail address
- Download and install Outlook Express
- Get your free Gmail address
- Outlook Express new version
- Create my own email address
- Browers for Windows list
- Get email address
- Color combinations for web sites and pages
- Create Yahoo ID