Check out the latest documentation.

Java Script

51Degrees code and data integrate well with both server side and client side frameworks and libraries. You can use server side device detection to augment your JavaScript with 51Degrees properties.

This feature will be useful for Web sites and projects that primarily use JavaScript to generate pages and fetch content on client devices. More often than not you will still need to know if the requesting device is mobile (or not) and if it supports features such as HTML canvas. This can be achieved by maintaining a set of regular expressions that will run first to determine if the device is mobile and would only then allow the main JavaScript logic to fetch content. This approach is far from ideal:  it can be inaccurate and only provides a fraction of the information that is available in the 51Degrees data files.

By using server side device detection you can obtain a fuller list of properties that are of interest to you and include them in your JavaScript page or application. This approach speeds up the loading time on your client devices, provides considerably more data for mobile devices and removes the overhead of manually maintaining a set of regular expressions for device detection.

Using Detection Results in Java Script

The following needs to be added to the HTML page header before accessing the FODF variable.



Use on client side like:

									if (FODF.IsMobile) {
  // Do something for mobiles only.



By default all available properties are included. To only include a subset of properties add them to the query string:



FODF object with properties looks like:

									var FODF={ IsMobile:false, BrowserName:"Chrome", BrowserVersion:33 };