Detect Browser/Platform/Engine And Add Related Classes To Html - jquery.ua.js

File Size: 5.71 KB
Views Total: 594
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Detect Browser/Platform/Engine And Add Related Classes To Html - jquery.ua.js

A small browser detection plugin that detects browser/platform/engine information using the user agent and adds related CSS classes to the <html> element.

Supported Browsers:

  • Internet Explorer (Mobile)
  • Internet Explorer
  • Firefox
  • Chrome
  • Safari
  • Opera

Supported Platforms:

  • Windows Phone
  • Windows
  • iPad
  • iPod
  • iPhone
  • Mac
  • Android
  • Blackberry
  • Linux

Supported Engines:

  • Trident
  • Webkit
  • Gecko
  • Presto

How to use it:

1. Just include the minified version of the jquery.ua.js plugin after jQuery library and done.

<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/cdn/jquery.ua.min.js"></script>

2. Get the user agent information.

$.ua.platform.name
$.ua.platform.win
$.ua.platform.version
$.ua.platform.versionMajor
$.ua.platform.versionName
$.ua.platform.win10
$.ua.platform.mobile
$.ua.platform.tablet
$.ua.browser.name
$.ua.browser.chrome
$.ua.browser.version 
$.ua.browser.versionMajor
$.ua.engine.name
$.ua.engine.webkit
$.ua.engine.version
$.ua.engine.versionMajor

3. The example CSS classes added to the html tag within your document.

<html class="win win10 chrome chrome76 webkit webkit537">
  ...
</html>

This awesome jQuery plugin is developed by terkel. For more Advanced Usages, please check the demo page or visit the official website.