This time I will share jQuery Plugin and tutorial about Client Browser & Platform Detection Plugin – jQuery Depend, hope it will help you in programming stack.
Depend is a jQuery browser & platform detection plugin to detect client browser (type and version), OS, device type, and other util information using the user agent.
In addition, the plugin enables the developer to do some cool stuff if the browser and/or platform doesn’t fit the minimal requirements you specify.
How to use it:
1. Load the minified version of the jQuery Depend plugin from the dist
folder.
1 |
< script src = "/path/to/cdn/jquery.min.js" ></ script > |
2 |
< script src = "/path/to/dist/jquery.depend.min.js" ></ script > |
2. Get the browser type. Possible properties:
- original
- version
- opera
- operamini
- operamobile
- msie
- edge
- firefox
- chrome
- browser
- safari
- silk
- mercury
- webkit
- trident
- khtml
- gecko
- presto
- x86
- x64
- arm
- ia64
- unknown
3. Get the browser version. Possible properties:
- original
- major
- minor
- build
- revision
02 |
$.browser.version.original |
05 |
$.browser.version.major |
08 |
$.browser.version.minor |
11 |
$.browser.version.build |
14 |
$.browser.version.revision |
4. Get the OS & device type. Possible properties:
- type
- original
- tablet
- mobile
- pc
- ipad
- iphone
- ipod
- android
- windowsphone
- windows
- mac
- linux
- x86
- x64
- arm
- ia64
- unknown
5. Execute custom codes based on the Browser and Platform:
02 |
on: ($.browser.is( 'msie' ) && $.browser.version.isOrLess(8)), |
04 |
return 'IE, and version is or less than 8.0.' ; |
07 |
on: ($.browser.is( 'msie' ) && $.browser.version.isMoreThan(8)), |
09 |
return 'IE, and version is more than 8.0.' ; |
6. All possible API methods.
04 |
$.platform.is(string); |
07 |
browser.version.isEqual( major, minor, build, revision ); |
08 |
browser.version.isOrLess( major, minor, build, revision ); |
09 |
browser.version.isLessThan( major, minor, build, revision ); |
10 |
browser.version.isOrMore( major, minor, build, revision ); |
11 |
browser.version.isMoreThan( major, minor, build, revision ); |
This awesome jQuery plugin is developed by garafu. For more Advanced Usages, please check the demo page or visit the official website.