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 9

Client Detection

What’s in This Chapter?

  • Using capability detection
  • The history of user-agent detection
  • When to use each type of detection

Although browser vendors have made a concerted effort to implement common interfaces, the fact remains that each browser presents its own capabilities and flaws. Browsers that are available cross-platform often have different issues, even though they are technically the same version. These differences force web developers to either design for the lowest common denominator or, more commonly, use various methods of client detection to work with or around limitations.

Client detection remains one of the most controversial topics in web development. The idea that browsers should support a common set of functionality pervades most conversations on the topic. In an ideal world, this would be the case. In reality, however, there are enough browser differences and quirks that client detection becomes not just an afterthought but also a vital part of the development strategy.

There are several approaches to determine the web client being used, and each has advantages and disadvantages. It’s important to understand that client detection should be the very last step in solving a problem; whenever a more common solution is available, that solution should be used. Design for the most common solution first and then augment it with browser-specific solutions later.

Capability Detection

The most commonly used and widely accepted form of client ...

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