Skip to content
Simple user agent detection library. - Node.js or Browser supported
JavaScript Shell HTML Makefile
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
spec Added a test case and Android 5.x support
tests Added: ie 12 edge and pc chrome/firefox/safari support
.gitignore Added mobile function.
.jshintrc Released 0.9.3
LICENSE first commit
Makefile Updated README.md
README.md
bower.json Added bowser and changed package name of npm
build.sh
package.json Added: ie 12 edge and pc chrome/firefox/safari support
setver
sua.js Added: ie 12 edge and pc chrome/firefox/safari support
sua.min.js Added: ie 12 edge and pc chrome/firefox/safari support

README.md

sua

Simple user agent detection library. (Node.js or Browser supported)

Install (NPM or Bower)

$ npm install sua.js
or
$ bower install sua.js

Feature

Support Browser

  • ua.Android 2.1
  • ua.Android 2.2
  • ua.Android 2.3
  • ua.Android 3.x
  • ua.Android 4.x
  • ua.Android 5.0
  • ua.Android 5.1
  • ua.iphone (IOS4)
  • ua.iphone (IOS5)
  • ua.iphone (IOS6)
  • ua.iphone (IOS7)
  • ua.iphone (IOS8)
  • ua.iphone (IOS9)
  • ua.iphone (IOS4-ipad)
  • ua.iphone (IOS5-ipad)
  • ua.iphone (IOS6-ipad)
  • ua.iphone (IOS7-ipad)
  • ua.iphone (IOS8-ipad)
  • ua.iphone (IOS9-ipad)
  • ua.iphone5 (hardware)
  • ua.blackberry
  • ua.webos
  • ua.touchpad
  • ua.kindle
  • ua.silk
  • ua.bb10
  • ua.rimtabletos
  • ua.playbook
  • ua.ds
  • ua.psp
  • ua.psvita
  • ua.windowsphone
  • ua.safari
  • ua.xbox
  • ua.ie11 Edge
  • ua.ie11
  • ua.ie10
  • ua.ie9
  • ua.android.firefox
  • ua.webview.twitter
  • ua.chrome pc
  • ua.firefox pc
  • ua.safari pc

Build

$ make build # output: sua.min.js

test

Browser : $ ./spec/index.html

Terminal : $ make test

Use

<script src="sua.js" />

<script>
  // window.sua.setup();
  window.sua.setup('Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25');

  console.log(sua.browser.version);

  JSON.stringify(sua.os, null, "    ");
  > "{
  >   "iphone": true,
  >   "ios": true,
  >   "version": "6.0",
  >   "tablet": false,
  >   "phone": true
  > }"

  JSON.stringify(sua.iphone, null, "    ")
  > "[
  >   "iPhone OS 6_0",
  >   "iPhone OS",
  >   "6_0"
  > ]"
</script>

file size

sua.js (size: 10721 byte) optimize none
sua.min.js (size: 3559 byte) optimize uglify2

LICENSE

@see : LICENSE

Something went wrong with that request. Please try again.