spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / prof_java2 / 1 To page 1To page 2To page 3To page 4current page
[previous]

Data Center Architect
The Computer Merchant, Ltd
US-MA-chelsea

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Professional JavaScript for Web Developers: JavaScript in the Browser, Pt. 2

The screen object

Although most information about the user’s system is hidden for security reasons, it is possible to get a certain amount of information about the user’s monitor using the screen object (which, you may have already guessed, is a property of window as well).

The screen object typically contains the following properties (although, as usual, many browsers add their own properties):

  • availHeight - the height of the screen (in pixels) available for use by windows. This takes into account the space needed by operating system elements such as the Windows taskbar.
  • availWidth - the width of the screen (in pixels) available for use by windows
  • colorDepth - the number of bits used to represent colors. For most systems, this is 32.
  • height - the height of the screen in pixels
  • width - the width of the screen in pixels

The availHeight and availWidth properties are useful when determining the new size for a window. For example, to fill up the user's screen, you could use this code:

    window.moveTo(0, 0);
    window.resizeTo(screen.availWidth, screen.availHeight);
Besides that, most of this data is used in conjunction with site traffic tools to determine the graphical capabilities of users.

Summary

This chapter introduced using JavaScript inside of Web browsers. It covered how to include JavaScript code in both HTML and SVG pages, explaining the differences between the two. It also discussed how XHTML has changed how JavaScript is included in HTML pages and the best way to prepare for the future in this regard.

Later in the chapter, you learned about the Browser Object Model and the various objects it supplies. You learned that the window object is the center of the JavaScript universe, and all the other BOM objects are actually just properties of window.

The chapter explained how to manipulate browser windows and frames, moving and resizing them using JavaScript. Using the location object, you learned how to access and alter a window’s location and, using the history object, how to go back and forward to pages the user has already visited.

Finally, you learned how to retrieve information about a user’s Web browser and screen by using the navigator and screen objects.

Reproduced from "Professional JavaScript for Web Developers" by permission of WROX. ISBN 0764579088, copyright 2005. All rights reserved. See WROX for more information.

 

 

 

 

 

 

 

 

 

 

 

home / programming / prof_java2 / 1 To page 1To page 2To page 3To page 4current page
[previous]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: March 27 2003
Revised: June 27, 2005

URL: http://webreference.com/programming/prof_java2/1