browser platform detection depend - Free Download Client Browser & Platform Detection Plugin - jQuery Depend

Free Download Client Browser & Platform Detection Plugin – jQuery Depend

Posted on

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.

browser platform detection depend - Free Download Client Browser & Platform Detection Plugin - jQuery Depend
File Size: 38.1 KB
Views Total: 350
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

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
1 // chrome
2 $.browser.original

3. Get the browser version. Possible properties:

  • original
  • major
  • minor
  • build
  • revision
01 // 83.0.4103.97
02 $.browser.version.original
03  
04 // 83
05 $.browser.version.major
06  
07 // 0
08 $.browser.version.minor
09  
10 // 4103
11 $.browser.version.build
12  
13 // 97
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
1 // Windows
2 $.platform.original

5. Execute custom codes based on the Browser and Platform:

01 $.depend({
02   on: ($.browser.is('msie') && $.browser.version.isOrLess(8)),
03   exe: function () {
04     return 'IE, and version is or less than 8.0.';
05   }
06 }, {
07   on: ($.browser.is('msie') && $.browser.version.isMoreThan(8)),
08   exe: function () {
09     return 'IE, and version is more than 8.0.';
10   }
11 }, {
12   exe: function () {
13     return 'not IE.';
14   }
15 });

6. All possible API methods.

01 // checks if is a certain browser & OS & device type
02 // returns true or false
03 $.browser.is(string);
04 $.platform.is(string);
05  
06 // checks if the browser fits the minimal requirements
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.