o      The screen object provides you with access to properties of the user’s computer display screen within your JavaScript applications.

o   Some of the available properties are:

Property

Description

availHeight

The pixel height of the user’s screen minus the toolbar and any other permanent objects (eg the Windows Taskbar)

availWidth

As availHeight, but dealing with horizontal space

colorDepth

The maximum number of colours the user’s screen can display (in bit format, eg 24 bit, 16 bit etc)

heightThe true pixel height of the user’s display

width

The true pixel width of the user’s display

o      The left and top parameters of the open() method enable you to specify the position of a window on screen by specifying the number of pixels from the left and top of the screen respectively.

o     If you need to use a variable to specify the value of a parameter in the open() method, you would do so as follows:

window.open(“index.html”, “window_name”,“width=200,height=200,left=”+var_left+“top=”+var_top);

                       Where var_left and var_top are the appropriate variables.

o       Note the use of the + operator to ensure that the third parameter in the open() method remains as one string when variables are added.

o       In order to centre the window on the user’s screen, a little simple geometry is required. The centre of the screen is obviously the point found when we take the width of the screen divided by two, and take the height of the screen divided by two. However, if we set the window’s top and left values to these coordinates, the top left corner of the window will be centred, not the window itself.

o      In order to centre the window, we need to subtract half of the window’s height from our top value, and half of the window’s width from our left value. A simple script to accomplish this is as follows:

         win_width = 200; win_height = 200;

    win_left = (screen.availWidth/2)– (win_width/2);

    win_top = (screen.availHeight/2)– (win_height/2);

o       By using this script, the values of win_left and win_top will be set correctly for any window using win_width and win_height appropriately to be centred on the screen.

Project

o      Open your previous project file, and save it under the name chapter_26.html.

o     Modify your existing code to ensure that the logo appears centred on the user’s screen. If possible, do not modify your original function by doing anything more than two new functions – get_win_left( width ) and get_win_top( height ).