Pages

Monday, February 8, 2010

JavaScript Browser Detection

The Navigator object contains information about the visitor's browser.
Browser Detection
Almost everything in this tutorial works on all JavaScript-enabled browsers. However, there are some things that just don't work on certain browsers - especially on older browsers.
So, sometimes it can be very useful to detect the visitor's browser, and then serve up the appropriate information.
The best way to do this is to make your web pages smart enough to look one way to some browsers and another way to other browsers.
The Navigator object can be used for this purpose.
The Navigator object contains information about the visitor's browser name, version, and more.
Note: There is no public standard that applies to the navigator object, but all major browsers support it.
The Navigator Object
The Navigator object contains all information about the visitor's browser. We are going to look at two properties of the Navigator object:
appName - holds the name of the browser
appVersion - holds, among other things, the version of the browser

JavaScript Objects Introduction

JavaScript Objects Introduction

JavaScript is an Object Oriented Programming (OOP) language.
An OOP language allows you to define your own objects and make your own variable types.
Object Oriented Programming
JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types.
However, creating your own objects will be explained later, in the Advanced JavaScript section. We will start by looking at the built-in JavaScript objects, and how they are used. The next pages will explain each built-in JavaScript object in detail.
Note that an object is just a special kind of data. An object has properties and methods.