You are previewing Professional: JavaScript® for Web Developers, Third Edition.

Professional: JavaScript® for Web Developers, Third Edition

  1. Cover
  2. Contents
  3. Introduction
  4. Chapter 1: What is Javascript?
    1. A Short History
    2. JavaScript Implementations
    3. JavaScript Versions
    4. Summary
  5. Chapter 2: Javascript in Html
    1. The <script> Element
    2. Inline Code versus External Files
    3. Document Modes
    4. The <noscript> Element
    5. Summary
  6. Chapter 3: Language Basics
    1. Syntax
    2. Keywords and Reserved Words
    3. Variables
    4. Data Types
    5. Operators
    6. Statements
    7. Functions
    8. Summary
  7. Chapter 4: Variables, Scope, and Memory
    1. Primitive and Reference Values
    2. Execution Context and Scope
    3. Garbage Collection
    4. Summary
  8. Chapter 5: Reference Types
    1. The Object Type
    2. The Array Type
    3. The Date Type
    4. The RegExp Type
    5. The Function Type
    6. Primitive Wrapper Types
    7. Singleton Built-in Objects
    8. Summary
  9. Chapter 6: Object-Oriented Programming
    1. Understanding Objects
    2. Object Creation
    3. Inheritance
    4. Summary
  10. Chapter 7: Function Expressions
    1. Recursion
    2. Closures
    3. Mimicking Block Scope
    4. Private Variables
    5. Summary
  11. Chapter 8: The Browser Object Model
    1. The window Object
    2. The location Object
    3. The Navigator Object
    4. The screen Object
    5. The history Object
    6. Summary
  12. Chapter 9: Client Detection
    1. Capability Detection
    2. Quirks Detection
    3. User-Agent Detection
    4. Summary
  13. Chapter 10: The Document Object Model
    1. Hierarchy of Nodes
    2. Working with the DOM
    3. Summary
  14. Chapter 11: Dom Extensions
    1. Selectors API
    2. Element Traversal
    3. HTML5
    4. Proprietary Extensions
    5. Summary
  15. Chapter 12: Dom Levels 2 and 3
    1. DOM Changes
    2. Styles
    3. Traversals
    4. Ranges
    5. Summary
  16. Chapter 13: Events
    1. Event Flow
    2. Event Handlers
    3. The Event Object
    4. Event Types
    5. Memory and Performance
    6. Simulating Events
    7. Summary
  17. Chapter 14: Scripting Forms
    1. Form Basics
    2. Scripting Text Boxes
    3. Scripting Select Boxes
    4. Form Serialization
    5. Rich Text Editing
    6. Summary
  18. Chapter 15: Graphics With Canvas
    1. Basic Usage
    2. The 2D Context
    3. WebGL
    4. Summary
  19. Chapter 16: Html5 Scripting
    1. Cross-Document Messaging
    2. Native Drag and Drop
    3. Media Elements
    4. History State Management
    5. Summary
  20. Chapter 17: Error Handling and Debugging
    1. Browser Error Reporting
    2. Error Handling
    3. Debugging Techniques
    4. Common Internet Explorer Errors
    5. Summary
  21. Chapter 18: Xml in Javascript
    1. XML DOM Support in Browsers
    2. XPath Support in Browsers
    3. XSLT Support in Browsers
    4. Summary
  22. Chapter 19: Ecmascript For Xml
    1. E4X Types
    2. General Usage
    3. Other Changes
    4. Enabling Full E4X
    5. Summary
  23. Chapter 20: JSON
    1. Syntax
    2. Parsing and Serialization
    3. Summary
  24. Chapter 21: Ajax and Comet
    1. The XMLHttpRequest Object
    2. XMLHttpRequest Level 2
    3. Progress Events
    4. Cross-Origin Resource Sharing
    5. Alternate Cross-Domain Techniques
    6. Security
    7. Summary
  25. Chapter 22: Advanced Techniques
    1. Advanced Functions
    2. Tamper-Proof Objects
    3. Advanced Timers
    4. Custom Events
    5. Drag and Drop
    6. Summary
  26. Chapter 23: Offline Applications and Client-Side Storage
    1. Offline Detection
    2. Application Cache
    3. Data Storage
    4. Summary
  27. Chapter 24: Best Practices
    1. Maintainability
    2. Performance
    3. Deployment
    4. Summary
  28. Chapter 25: Emerging APIS
    1. RequestAnimationFrame()
    2. Page Visibility API
    3. Geolocation API
    4. File API
    5. Web Timing
    6. Web Workers
    7. Summary
  29. Appendix A: Ecmascript Harmony
  30. Appendix B: Strict Mode
  31. Appendix C: Javascript Libraries
  32. Appendix D: Javascript TOOLS
O'Reilly logo

Chapter 8

The Browser Object Model

What’s in This Chapter?

  • Understanding the window object, the core of the BOM
  • Controlling windows, frames, and pop-ups
  • Page information from the location object
  • Using the navigator object to learn about the browser

Though ECMAScript describes it as the core of JavaScript, the Browser Object Model (BOM) is really the core of using JavaScript on the Web. The BOM provides objects that expose browser functionality independent of any web page content. For years, a lack of any real specification made the BOM both interesting and problematic, because browser vendors were free to augment it as they saw fit. The commonalities between browsers became de facto standards that have survived browser development mostly for the purpose of interoperability. Part of the HTML5 specification now covers the major aspects of the BOM, as the W3C seeks to standardize one of the most fundamental parts of JavaScript in the browser.

The window Object

At the core of the BOM is the window object, which represents an instance of the browser. The window object serves a dual purpose in browsers, acting as the JavaScript interface to the browser window and the ECMAScript Global object. This means that every object, variable, and function defined in a web page uses window as its Global object and has access to methods like parseInt().

The Global Scope

Since the window object doubles as the ECMAScript Global object, all variables and functions declared globally become properties ...

The best content for your career. Discover unlimited learning on demand for around $1/day.