Jekyll One

Platform.js

platform detection library

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

Examples

Platform.js is for informational purposes only & not intended as a substitution for feature detection/inference checks.
// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition
//
platform.name; // 'IE'
platform.version; // '10.0'
platform.layout; // 'Trident'
platform.os; // 'Windows Server 2008 R2 / 7 x64'
platform.description; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) on Windows Server 2008 R2 / 7 x64'
// or on an iPad
//
platform.name; // 'Safari'
platform.version; // '5.1'
platform.product; // 'iPad'
platform.manufacturer; // 'Apple'
platform.layout; // 'WebKit'
platform.os; // 'iOS 5.0'
platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'
// or 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');
info.name; // 'Opera'
info.version; // '11.52'
info.layout; // 'Presto'
info.os; // 'Mac OS X 10.7.2'
info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'

API

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 browser’s 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=navigator.userAgent])

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.

Returns (string): Returns platform.description if available, else an empty string.

platform.ua

The browser’s user agent string.

platform.version

The browser/environment version.