Jekyll One

QuickSearch

The platform.js detection library works on nearly all JavaScript platforms. Using platform.js, it becomes very easy to detect the browser used by vistors just by writing one line of JavaScript code.

J1 Integration

The detection library platform.js is integrated in the Javascript core library of J1 Theme and exports all available methods (like platform.name) to the document scope (window).

Examples

The following examples show how to collect platform and UA (user agent) information and parse an existing UA string into (info) variables.

Chrome Browser (August 2022) on Windows 10 64 bit edition
var platform_name         = platform.name;          // Chrome
var platform_version      = platform.version;       // 104.0.0.0
var platform_layout       = platform.layout;        // Blink
var platform_os           = platform.os;            // Windows 10 64 bit
var platform_description  = platform.description;   // Chrome 104.0.0.0 on Windows 10 64 bit
Safari Browser on iPad
var platform_name         = platform.name;            // Safari
var platform_version      = platform.version;         // 5.1
var platform_product      = platform.product;         // iPad
var platform_manufacturer = platform.manufacturer;    // Apple
var platform_layout       = platform.layout;          // WebKit
var platform_os           = platform.os;              // iOS 5.0
var platform_description  = platform.description;     // Safari 5.1 on Apple iPad (iOS 5.0)
Parsing a given UA string
var info = platform.parse('
  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv:2.0)
   Gecko/20100101 Firefox/4.0 Opera 11.52
');
var info_name             = info.name;                // Opera
var info_version          = info.version;             // 11.52
var info_layout           = info.layout;              // Presto
var info_os               = info.os;                  // Mac OS X 10.7.2
var info_description      = info.description;         // Opera 11.52

Available methods

Table 1. Available methods
Method Description

platform.os.architecture

The CPU architecture the OS is built for.

platform.os.family

The family of the OS. Common values include:

  • Windows Server 2008 R2, Windows Server 2008

  • Windows Vista | XP | 7 | 10 | 11

  • OS X

  • Ubuntu, Debian, Fedora, Red Hat, SuSE,

  • Android, iOS, Windows Phone

platform.os.version

The version of the OS.

platform.description

The platform description.

platform.layout

The name of the browsers layout engine. The list of common layout engines include:

  • Blink

  • EdgeHTML

  • Gecko

  • Trident

  • WebKit

platform.manufacturer

The name of the product’s manufacturer. The list of manufacturers include:

  • Apple

  • Archos

  • Amazon

  • Asus

  • Barnes & Noble

  • BlackBerry

  • Google

  • HP

  • HTC

  • LG

  • Microsoft

  • Motorola

  • Nintendo

  • Nokia

  • Samsung

  • Sony

platform.name

The name of the browser/environment. The list of common browser names include:

  • Chrome

  • Electron

  • Firefox

  • Firefox for iOS

  • IE

  • Microsoft Edge

  • PhantomJS

  • Safari

  • SeaMonkey

  • Silk

  • Opera, Mini and "Opera Mobile

Mobile versions of some browsers have Mobile appended to their name like Chrome Mobile, Firefox Mobile, IE Mobile and Opera Mobile.

platform.os

The name of the operating system.

platform.parse()

Creates a new platform object.

platform.parse('<UA string>')

platform.prerelease

The alpha/beta release indicator.

platform.product

The name of the product hosting the browser. The list of common products include:

  • BlackBerry

  • Galaxy S4

  • Lumia

  • iPad, iPod, iPhone

  • Kindle, Kindle Fire

  • Nexus, Nook, PlayBook, TouchPad, Transformer

platform.toString()

Returns platform.description when the platform object is coerced to a string if available, else an empty string.

platform.ua

The browser’s user agent string.

platform.version

The browser/environment version.

Further Reading

  • Home: Platform.js

  • Docs: Docs@Platform.js