You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project sets up a server using WhichBrowser that exposes an API for browser detection that can be used by JavaScript in the browser. This project uses the [WhichBrowser/Parser](https://github.com/WhichBrowser/Parser) library for the actual useragent sniffing.
3
+
This is an extremely complicated and almost completely useless browser sniffing library. Useless because you shouldn't use browser sniffing. So stop right now and go read something about feature detecting instead. I'm serious. Go away. You'll thank me later.
4
+
5
+
6
+
WhichBrowser/Server
7
+
===================
8
+
9
+
This project sets up a server using WhichBrowser that exposes an API for browser detection that can be used by JavaScript in the browser. This project uses the [WhichBrowser/Parser-PHP](https://github.com/WhichBrowser/Parser-PHP) library for the actual useragent sniffing.
A JavaScript version of WhichBrowser for use with Node.js on the server
12
24
13
25
---
14
26
@@ -87,10 +99,10 @@ Another possiblity is to query the object:
87
99
result.isType('desktop')
88
100
// true
89
101
90
-
result.isType('mobile', 'tablet', 'media')
102
+
result.isType('mobile', 'tablet', 'media')
91
103
// false
92
104
93
-
result.isBrowser('Maxthon', '<', '4.0.5')
105
+
result.isBrowser('Maxthon', '<', '4.0.5')
94
106
// false
95
107
96
108
result.isOs('iOS', '>=', '5')
@@ -103,7 +115,7 @@ Another possiblity is to query the object:
103
115
You can also access these properties directly:
104
116
105
117
result.browser
106
-
// Chrome 27
118
+
// Chrome 27
107
119
108
120
result.engine
109
121
// Blink
@@ -151,27 +163,27 @@ After a new `WhichBrowser` object is created, it contains a number of properties
151
163
152
164
**Properties:**
153
165
154
-
*`browser`
166
+
*`browser`
155
167
an object that contains information about the browser itself
156
-
*`engine`
168
+
*`engine`
157
169
an object that contains information about the rendering engine
158
-
*`os`
170
+
*`os`
159
171
an object that contains information about the operating system
160
-
*`device`
172
+
*`device`
161
173
an object that contains information about the device
162
174
163
175
**Functions:**
164
176
165
-
`isType(type [,type [,type [,type]]])`
177
+
`isType(type [,type [,type [,type]]])`
166
178
If a single argument is used, the function returns `true` if the argument matches the `type` propery of `device` obejct. It can use multiple arguments in which case the function returns `true` if one of the arguments matches. If none of the arguments matches, it returns `false`
167
179
168
-
`isBrowser(name [, comparison, version])`
180
+
`isBrowser(name [, comparison, version])`
169
181
Is used to query the `name` and `version` property of the `browser` object. The funcion can contain a single argument to a simple comparison based on `name`, or three arguments to compare both `name` and `version`. The first argument always contains the name of the browser. The second arguments is a string that can container either `<`, `<=`, `=`, `=>` or `>`. The third is an integer, float or string that contains the version. You can use versions like `10`, `10.7` or `'10.7.4'`. For more information about how version comparisons are performed, please see the `is()` function of the `Version` object.
170
182
171
-
`isEngine(name [, comparison, version])`
183
+
`isEngine(name [, comparison, version])`
172
184
Is used to query the `name` and `version` property of the `engine` object. This function works in exactly the same way as `isBrowser`.
173
185
174
-
`isOs(name [, comparison, version])`
186
+
`isOs(name [, comparison, version])`
175
187
Is used to query the `name` and `version` property of the `os` object. This function works in exactly the same way as `isBrowser`.
176
188
177
189
@@ -181,17 +193,17 @@ The `Browser` object is used for the `browser` property of the main `WhichBrowse
181
193
182
194
**Properties:**
183
195
184
-
*`name`
196
+
*`name`
185
197
a string containing the name of the browser
186
-
*`version`
198
+
*`version`
187
199
a version object containing information about the version of the browser
188
-
*`stock`
200
+
*`stock`
189
201
a boolean, true if the browser is the default browser of the operating system, false otherwise
190
-
*`channel`
202
+
*`channel`
191
203
a string containing the distribution channel, ie. 'Nightly' or 'Next'.
192
-
*`mode`
204
+
*`mode`
193
205
a string that can contain the operating mode of the browser, ie. 'proxy'.
194
-
*`hidden`
206
+
*`hidden`
195
207
a boolean that is true if the browser does not have a name and is the default of the operating system.
196
208
197
209
@@ -201,9 +213,9 @@ The `Engine` object is used for the `engine` property of the main `WhichBrowser`
201
213
202
214
**Properties:**
203
215
204
-
*`name`
216
+
*`name`
205
217
a string containing the name of the rendering engine
206
-
*`version`
218
+
*`version`
207
219
a version object containing information about the version of the rendering engine
208
220
209
221
@@ -213,9 +225,9 @@ The `Os` object is used for the `os` property of the main `WhichBrowser` object
213
225
214
226
**Properties:**
215
227
216
-
*`name`
228
+
*`name`
217
229
a string containing the name of the operating system
218
-
*`version`
230
+
*`version`
219
231
a version object containing information about the version of the operating system
220
232
221
233
@@ -225,13 +237,13 @@ The `Device` object is used for the `device` property of the main `WhichBrowser`
225
237
226
238
**Properties:**
227
239
228
-
*`type`
240
+
*`type`
229
241
a string containing the type of the browser.
230
-
*`identified`
242
+
*`identified`
231
243
a boolean that is true if the device has been positively identified.
232
-
*`manufacturer`
244
+
*`manufacturer`
233
245
a string containing the manufacturer of the device, ie. 'Apple' or 'Samsung'.
234
-
*`model`
246
+
*`model`
235
247
as string containing the model of the device, ie. 'iPhone' or 'Galaxy S4'.
236
248
237
249
The `type` property can contain any value from the following list:
@@ -260,31 +272,31 @@ The `Version` object is used for the `version` property of the `browser`, `engin
260
272
261
273
**Properties:**
262
274
263
-
*`original`
275
+
*`original`
264
276
a string containing the original version number.
265
-
*`alias`
277
+
*`alias`
266
278
a string containing an alias for the version number, ie. 'XP' for Windows '5.1'.
267
-
*`details`
279
+
*`details`
268
280
an integer containing the number of digits of the version number that should be printed.
269
-
*`major`
281
+
*`major`
270
282
an integer containing the major version number.
271
-
*`minor`
283
+
*`minor`
272
284
an integer containing the minor version number.
273
-
*`type`
285
+
*`type`
274
286
a string containing a type indicator, ie. 'beta' or 'alpha'.
275
287
276
288
**Functions:**
277
289
278
-
`is(version)` or `is(comparison, version)`
290
+
`is(version)` or `is(comparison, version)`
279
291
Using this function it is easy to compare a version to another version. If you specify only one argument, this function will return if the versions are the same. You can also specify two arguments, in that case the first argument contains the comparison operator, such as `<`, `<=`, `=`, `=>` or `>`. The second argument is the version you want to compare it to. You can use versions like `10`, `10.7` or `'10.7.4'`, but be aware that `10` is not the same as `10.0`. For example if our OS version is `10.7.4`:
0 commit comments