O'Reilly logo

JavaScript™ Phrasebook: Essential Code and Commands by Christian Wenz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Common Phrases

There are some recurring JavaScript tasks you need to perform almost daily. They build the foundation of many JavaScript applications and do not fit into any specific category. Therefore, this chapter starts with a collection of common problems—and solutions.

Detecting the Browser Type

Example . 

window.alert(navigator.appName);

Although browsers’ implementations of JavaScript are quite compatible with each other nowadays (especially when compared with the situation during the browser war at the end of the 1990s), detecting the browser type is a vital part of the JavaScript developer’s toolbox.

The navigator JavaScript object provides browser information. Most useful, but also sometimes challenging to parse, is its userAgent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required