Library for client-side web browser judgment. It has been developed to work with a wide range of DHTML browsers, both old and new.
Prior to August 7, 2020, development was done at itozyun/web-doc-base.
Prime Minister Abe nearly loses the name of the school's chairman, who was told by Mrs. Akie that "his enthusiasm was wonderful". TV TOKYO, source (e.g. quotation)
- Features
- Folders
- Test Page
-
Usage
- Properties
-
Method
- conpare(v1, v2)
- Development
- License
- Even if the visitor has checked "Request desktop site" and the UA is spoofed, the correct engine will be retrieved. In addition, you can detect the viewer's intention to "Prefer desktop version".
- For your reference 『「デスクトップ版を表示する」にチェックを付けると平然とUAを偽装するAndroid用標準ブラウザの判定をムキになってしてみます』
- Third-party browsers for Android and iOS use the same WebView but have different viewport behavior, such as address bar behavior. Therefore, retrieve the brand name.
- For your reference 『尋常でないレベルでブラウザを判定するライブラリ、what-browser-am-iをnpmに公開しました』
- It works on IE4 or later because
in
operator andinstanceof
operator andtry~catch
statements are not used. Also, it works on mobile IE4 because it does not use regular expressions.
Directories | Sub Direcories | Description |
---|---|---|
dist/ | Placement of built files. | |
docs/ | The index.html file for executing the browser judgment is placed, but not attached to the npm package. If necessary, the contents can be found on github pages . | |
src/ | js | source codes |
js-externs | Variable and property names to be protected from renaming by specifying them in externs of the Closure Compiler. |
- Test page (or bit.ly/39Wvkct)
- HTTP version (or bit.ly/3ft54YC)
const whatBrowserAmI = require('what-browser-am-i');
console.log(whatBrowserAmI.ENGINE); // Trident
console.log(whatBrowserAmI.ENGINE_VERSION); // 8
or
<html>
<script src="./whatBrowserAmI.js"></script>
<script>
console.log(whatBrowserAmI.ENGINE); // Gecko
console.log(whatBrowserAmI.ENGINE_VERSION); // "1.9.1"
</script>
Property | Data type | Example |
---|---|---|
PLATFORM |
string |
|
PLATFORM_VERSION |
string|object |
|
ENGINE |
string |
|
ENGINE_VERSION |
string|object |
|
BRAND |
string |
|
BRAND_VERSION |
string|object |
|
DEVICE |
string |
|
DEVICE_VERSION |
string|object |
|
PCSITE_REQUESTED |
boolean |
true |
DEVICE_TYPE |
number |
Compares the size of the version number(string).
The last 0
is ignored, so "2.0.0"
and 2
are considered equal.
// Firefox 3.5<=
isFirefoxGte35 = whatBrowserAmI.Gecko && 0 <= whatBrowserAmI.conpare(whatBrowserAmI.ENGINE_VERSION, '1.9.1');
Name | Data type | Example |
---|---|---|
v1 | string|number |
"1.9.1" , 1.9
|
v2 | string|number |
"1.9.1" , 1.9
|
Value | Description | Example |
---|---|---|
1 |
v1 > v2 |
"1.9.1" > 1.9
|
0 |
v1 == v2 |
"1.9.0" == 1.9
|
-1 |
v1 < v2 |
"1.9.1" < "1.9.2"
|
git clone https://github.com/itozyun/what-browser-am-i
npm install
After making the changes under ./src/
, execute the following command.
Then browse docs/index.html with a browser to check.
gulp docs
Update the distribution files ./dist/index.js
and ./dist/whatBrowserAmI.js
with the following command.
gulp dist
web-doc-base/gulpfile.js is helpful.
- Compile with
DEFINE_WHAT_BROWSER_AM_I__MINIFY=true
. - All properties and names are provided numerically. This constant is located in
./src/js/0_global/*.js
. - web-doc-base/src/js-inline/dynamicViewPort.js, etc., to obtain the required values.
Closure Compiler @define
.
Variable | Data type | Default value | Note |
---|---|---|---|
DEFINE_WHAT_BROWSER_AM_I__MINIFY |
boolean |
false |
Since version 0.6 |
DEFINE_WHAT_BROWSER_AM_I__BRAND_ENABLED |
boolean |
true |
|
DEFINE_WHAT_BROWSER_AM_I__PCSITE_REQUESTED_ENABLED |
boolean |
true |
|
DEFINE_WHAT_BROWSER_AM_I__IOS_DEVICE_ENABLED |
boolean |
true |
|
DEFINE_WHAT_BROWSER_AM_I__DEVICE_TYPE_ENABLED |
boolean |
true |
what-browser-am-i is licensed under MIT License.
(C) 2021-2024 itozyun(outcloud.blogspot.com)