Quelltext der Datei: http://www.michaelster.ch/jsTestFolder/jQuery/jquery-browser-plugin/README.md

Dateigrösse: 3.62 kb

[Anzeige ohne Zeilennummern]


  1 [![NPM](https://nodei.co/npm/jquery.browser.png)](https://nodei.co/npm/jquery.browser/)
  2 
  3 [![Build Status](https://travis-ci.org/gabceb/jquery-browser-plugin.svg?branch=master)](https://travis-ci.org/gabceb/jquery-browser-plugin)
  4 
  5 A jQuery plugin for browser detection. jQuery v1.9.1 dropped support for browser detection, and this project aims to keep the detection up-to-date.
  6 
  7 ## Installation
  8 
  9 Include script *after* the jQuery library:
 10 ```html
 11 <script src="/path/to/jquery.browser.js"></script>
 12 ```
 13 
 14 Alternatively, you can use the plugin without jQuery by using the global object `jQBrowser` instead of `$.browser`.
 15 
 16 ## Usage
 17 
 18 Returns true if the current useragent is some version of Microsoft's Internet Explorer. Supports all IE versions including IE 11.
 19 
 20     $.browser.msie;
 21 
 22 Returns true if the current useragent is some version of a WebKit browser (Safari, Chrome and Opera 15+)
 23 
 24     $.browser.webkit;
 25 
 26 Returns true if the current useragent is some version of Firefox
 27 
 28     $.browser.mozilla;
 29 
 30 Reading the browser version
 31 
 32     $.browser.version
 33 
 34 You can also examine arbitrary useragents
 35 
 36     jQBrowser.uaMatch();
 37 
 38 ## Things not included in the original jQuery $.browser implementation
 39 
 40 - Detect specifically Windows, Mac, Linux, iPad, iPhone, iPod, Android, Kindle, BlackBerry, Chrome OS, and Windows Phone useragents
 41 
 42 ```javascript
 43     $.browser.android
 44     $.browser.blackberry
 45     $.browser.cros
 46     $.browser.ipad
 47     $.browser.iphone
 48     $.browser.ipod
 49     $.browser.kindle
 50     $.browser.linux
 51     $.browser.mac
 52     $.browser.msedge
 53     $.browser.playbook
 54     $.browser.silk
 55     $.browser.win
 56     $.browser["windows phone"]
 57 ```
 58 
 59 Alternatively, you can detect for generic classifications such as desktop or mobile
 60 
 61 ```javascript
 62     $.browser.desktop
 63     $.browser.mobile
 64 ```
 65 
 66 ```javascript
 67     // User Agent for Firefox on Windows
 68     User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0
 69     
 70     $.browser.desktop // Returns true as a boolean
 71 ```
 72 
 73 ```javascript
 74     // User Agent for Safari on iPhone
 75     User-Agent: Mozilla/5.0(iPhone; CPU iPhone OS 7_0_3 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B508 Safari/9537.53
 76     
 77     $.browser.mobile // Returns true as a boolean
 78 ```
 79 
 80 - Detect the browser's major version
 81 
 82 ```javascript
 83     // User Agent for Chrome
 84     // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36
 85     
 86     $.browser.versionNumber // Returns 32 as a number
 87 ```
 88 
 89 - Support for new useragent on IE 11
 90 - Support for Microsoft Edge
 91 - Support for WebKit based Opera browsers
 92 - Added testing using PhantomJS and different browser user agents
 93 
 94 ## Testing
 95 
 96 Testing for this plugin is done with [Casperjs v1.1](http://casperjs.org/) to take advantage of multiple phantomjs browsers with different user agents.
 97 
 98 For instructions on how to install [Casperjs v1.1](http://casperjs.org/) go to http://docs.casperjs.org/en/latest/installation.html
 99 
100 **Note: Testing requires Casperjs v1.1**
101 
102 Install the grunt-cli dependency by running `npm install -g grunt-cli`
103 Run `npm install` to install all dependencies including grunt and all tasks
104 
105 Once Casperjs and the grunt-cli npm package is installed you can execute all the tests by using:
106 
107     npm test
108 
109 ## Development
110 
111 - Source hosted at [GitHub](https://github.com/gabceb/jquery-browser-plugin)
112 - Report issues, questions, feature requests on [GitHub Issues](https://github.com/gabceb/jquery-browser-plugin/issues) 
113 
114 ## Attributions
115 
116 - [Examples and original implementation](http://api.jquery.com/jQuery.browser/)
117 - [Original Gist used for the plugin](https://gist.github.com/adeelejaz/4714079)
118