Browser L2
Browser L2
Browser
• Opening a window
• Giving the new window focus
• Window position
• Changing the content of window
• Closing the window
OPENING A WINDOW
• The Browser window is an object
• Whenever you want to do something with window, you must reference a
window and then the property or method of the window that you want to
access
• For example, an empty browser window that uses default setting can be
opened using
MyWindow = window.open( );
• The open( ) method returns a reference to the new window, which is
assigned to MyWindow variable
OPENING A WINDOW
• A window has properties like width, height, content and name etc.
• You set these attributes when you create the window by passing them as
parameters to the open( ) method
• The first parameter is full or relative URL of the web page that will
appear in the new window
• The second parameter is the name that you assign to the window
• The third parameter is a string that contains the style of window
OPENING A WINDOW
Window Styles
GIVING THE NEW WINDOW FOCUS
• The most recently opened window- that is, the last window opened –
usually has focus by default
• You can give a new window focus by calling focus() method
• E.g.
MyWindow.focus();
• The blur() method is used to remove the focus from current window, i.e. it
sends the new open window to the background
WINDOW POSITION
• The browser determines the location on the screen where the window
will be displayed
• However, you can specify the location by setting the left and top
properties of the new window when you create it
• Screen resolution setting differ from computer to computer, so the pixel
setting you specify for the position of new window will appear differently
if user’s screen is set at different resolution
• So, some java script developers specify relative positions when setting
left and top properties of new window
• You can find the screen resolution by using screen object and its
methods
WINDOW POSITION
• Properties of screen object