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.
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
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)
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
Method | Description | ||
---|---|---|---|
| The CPU architecture the OS is built for. | ||
| The family of the OS. Common values include:
| ||
| The version of the OS. | ||
| The platform description. | ||
| The name of the browsers layout engine. The list of common layout engines include:
| ||
| The name of the product’s manufacturer. The list of manufacturers include:
| ||
| The name of the browser/environment. The list of common browser names include:
| ||
| The name of the operating system. | ||
| Creates a new platform object.
| ||
| The alpha/beta release indicator. | ||
| The name of the product hosting the browser. The list of common products include:
| ||
| Returns | ||
| The browser’s user agent string. | ||
| The browser/environment version. |
Further Reading
-
Home: Platform.js
-
Docs: Docs@Platform.js