mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Update readme.md modify node example
This commit is contained in:
parent
9cad6a0f2d
commit
8c94018351
23
readme.md
23
readme.md
@ -149,15 +149,6 @@ Windows [Phone/Mobile], Zenwalk
|
|||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using requirejs
|
|
||||||
|
|
||||||
```js
|
|
||||||
require(['ua-parser'], function(UAParser) {
|
|
||||||
var parser = new UAParser();
|
|
||||||
console.log(parser.getResult());
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using node.js
|
### Using node.js
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -167,7 +158,17 @@ $ npm install ua-parser-js
|
|||||||
```js
|
```js
|
||||||
var UAParser = require('ua-parser-js');
|
var UAParser = require('ua-parser-js');
|
||||||
var parser = new UAParser();
|
var parser = new UAParser();
|
||||||
console.log(parser.getResult());
|
var ua = request.headers['user-agent']; // user-agent header from an HTTP request
|
||||||
|
console.log(parser.setUA(ua).getResult());
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using requirejs
|
||||||
|
|
||||||
|
```js
|
||||||
|
require(['ua-parser'], function(UAParser) {
|
||||||
|
var parser = new UAParser();
|
||||||
|
console.log(parser.getResult());
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using component
|
### Using component
|
||||||
@ -190,7 +191,7 @@ $ bower install ua-parser-js
|
|||||||
|
|
||||||
### Using jQuery.ua
|
### Using jQuery.ua
|
||||||
|
|
||||||
Although written in vanilla js (which means it doesn't depends on jQuery), if you're using jQuery, this library will automatically detect and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
|
Although written in vanilla js (which means it doesn't depends on jQuery), this library will automatically detect if jQuery is present and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// In browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
|
// In browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user