lancedikson / bowser Goto Github PK
View Code? Open in Web Editor NEWa browser detector
License: Other
a browser detector
License: Other
!function (name, definition) {
if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
else if (typeof define == 'function' && define.amd) define(definition)
else this[name] = definition()
}('bowser', function () {
May be it should be module.exports['bowser']
?
Is this repository dead ??!!
Last commit was on Apr 30, 2014
Report from a project that this breaks a webpage with zero errors
Hi
I had some issues with bowser in our javascript widget in IE11. IE debugger delivers following error:
if (version) { version = version[0].split('/')[1]; } else { version = /Opera\/[\.\d]+/.exec(ua)[0].split('/')[1]; }
Unable to get property '0' of undefined or null reference.
If I force IE11 to use IE10 Engine via meta tag (<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10"/>
) the errors doesn't accour.
Maybe someone else has a similar problem with bowser.
Is there any plan to update the npm package to include the os detection changes that were merged a couple days ago?
When you are using IE 10 in Compatibility mode, userAgent string contains 'MSIE 7.0' and 'Trident/6.0'
Bowser is detecting it as IE 7.
Not sure if this is an intended feature as it's displayed in compatibility, but the actual IE version is IE10
Hi,
Are there any plans for supporting typescript definitions? If so, when can we get that type file?
Thank you in advance.
In my app, I want to check which browser is being used.
bowser.name generally gives me the name of the browser, except for Safari on iPad, which returns "iPad" as the name. Why is this?
Checking for mobile
and tablet
can potentially cause false positives on certain Windows 8 devices (in our case a Asus X551M but users reported issues from MS Surface's as well).
We did not catch this using the MS provided VM's.
I realize that this is not technically a bug in bowser but I wanted to put this out there in case anybody else runs into the same issue.
To get around this we are now doing the following:
if ((bowser.tablet || bowser.mobile) && !bowser.msie) { etc }
Add a LICENSE file.
I am missing a correct detection of the Ubuntu Touch smartphone device.
"Mozilla/5.0 (Linux; Ubuntu 14.04 like Android 4.4) AppleWebKit/537.36 Chromium/35.0.1870.2 Mobile Safari/537.36"
If I'm using Chromium it's detects as Chrome.
http://en.wikipedia.org/wiki/Spartan_%28browser%29
'Spartan" is the codename of a web browser under development by Microsoft. Officially unveiled on January 21, 2015, and first publicly released as a preview on March 30, 2015, it will replace Internet Explorer as the default browser of Windows 10 PCs, smartphones and tablets.'
Is support for detection of Spartan planned?
Or can this be achieved using the existing code?
Thanks in advance.
When I minify all my JS, including the bowser library will cause an error — seems like the latest build is missing a semi-colon at the very end.
Vivaldi browser shows up as Chrome version 44.
Can you please provide a tag and register it for bower install?
Moto X on Chrome reports the following UserAgent:
Mozilla/5.0 (Linux; Android 4.4.4; XT1032 Build/KXB21.14-L1.40) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.102 Mobile Safari/537.36
See subject, bowser.version === "9.0" on IE11
Mozilla/5.0 (Android; Mobile; rv:30.0) Gecko/30.0 Firefox/30.0
Because of https://github.com/ded/bowser/blob/1a70355/bowser.js#L92
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference and http://lawrencemandel.com/2012/07/27/decision-made-firefox-os-user-agent-string/
please add ucbrowser support to this library
Hi, I don't know if I missing something, or this is a bug, but when I included the browser.js, I got error in Chrome console :Uncaught SyntaxError: Invalid regular expression: missing /
So, I just commented this line, and now it's works, but I don't know it there is some bug or I did something wrong...
Right now you have functions like if browsers = chrome then.
It would be nice to just write the browser to a variable for use later. This is extremely useful if you add a class to body with the browser name (sorta like modernizr).
some like this
var browser = detect.browser
I'm using the wonderful Ghost Inspector (https://ghostinspector.com/) to run automated tests on my app and need to ensure that the requests from them bypass my browser minimum requirements check, in Ghost Inspector you can set a custom user agent string but how would I set about bypassing the browser check if that's present... currently I have:
if ((bowser.msie && bowser.version < 8) || (!bowser.ios && !training.hasFlash())) {
if (typeof unsupported_redirect_path!="undefined") {
window.location = unsupported_redirect_path;
}
}
The Amazon Slik Browser has a "like chrome" in the user agent string, so
else if (/silk/i.test(ua)) {
must be before
else if (/chrome|crios|crmo/i.test(ua)) {
It looks like _detect
is exposed for testing bowser, and obviously it's indicated as private via the underscore. I imagine bowser could be useful for use in node where you could give it UA strings to parse, rather than having it grab the document's, in the case of the browser.
Of course if you feel that bowser is a browser-exclusive module I understand. There are, after all, other modules that detect more than bowser does, but I appreciate its leanness.
Since Windows 10 will be released in one month, it would be nice if detection of Microsoft's newest browser could be included before then. Here is an example UA string from MSDN:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0
You can find our UA strings here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference#Firefox_for_iOS
Firefox for iOS uses the same WKWebView as Safari for iOS. In theory we are on parity with Safari functionality.
Thanks!
Does that sound a little racist or it's just an emphasizing of the distressful fact?
I have a PhoneGap application that displays a “platform not supported” banner on the login page when Bowser detects a browser that does not fit my criteria of supported platform and supported version.
My base logic is set up like this:
var isSupported = Bowser[platform] && Bowser.version >= minSupportedVersion;
where:
Bowser[‘ios’] && Bowser.version >= '8'
But when I use an iPad with any of these user agents:
Mozilla/5.0 (iPad; CPU OS 9_0_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13A452
Mozilla/5.0 (iPad; CPU OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H143
Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H321
isSupported is set to false, and the user is erroneously shown that they are using an unsupported browser. This behavior does not present itself when I’m detecting traditional desktop browsers like Chrome or Internet Explorer (the library correctly detects these platforms).
Is something in my logic incorrect, or is the library not reporting something correctly?
It would be really cool if the Operating System detection was part of the public api. I'm using bowser to log information for bug reports and ideally I'd know: OS, OS version, Browser, Browser Version.
Feature Suggestion:
It seems that it would be relatively common use case to desire to know if the agent is a search bot, so building in the user agents for common search bots seems like a reasonable feature.
Google: https://support.google.com/webmasters/answer/1061943?hl=en
Bing: https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0
Hi,
on android using firefox, bowser returns same as on android default browser.
The UA is Mozilla/5.0 (Android; Tablet; rv:27.0) Gecko/27.0 Firefox 27.0
Thank you
please add ucbrowser support to this library
A web app opened on iOS via Safari can be in 3 states: standard web browser, standalone, UIWebView:
http://stackoverflow.com/questions/4460205/detect-ipad-iphone-webview-via-javascript
This could be useful as, for example, UIWebViews have some limitations as opposed to standard Safari.
Puffin is a popular browser for mobile. I have hacked part of the code to read its user agent string. Puffin FAQ (https://www.puffinbrowser.com/faq/ gives format of user agent at bottom of the page).
Not sure about whether the order makes sense or whether there are broader concerns to worry about.
if (/puffin/i.test(ua)) {
var puffinMatch = getFirstMatch(/(?:puffin)[\/](\d+(\.\d+)?(\.\d+)?..)/i);
var puffinLength = puffinMatch.length;
result = {
name: 'Puffin'
, puffin: t
, version: puffinMatch.substring(0, puffinLength - 2)
, puffinDevice: puffinMatch.substring(puffinLength - 2)
}
var firstPuffinCharacter = result.puffinDevice.substring(0, 1);
var secondPuffinCharacter = result.puffinDevice.substring(1);
if (firstPuffinCharacter == 'A'){
result.android = t;
result.mobile = t;
} else if (firstPuffinCharacter == 'I'){
result.ios = t;
result.mobile = t;
} else {
alert("Puffin may have changed its user agent string format - submit feedback at top right");
}
if (secondPuffinCharacter == 'T'){
result.tablet = t;
} else if (secondPuffinCharacter != 'P'){
alert("Puffin may have changed its user agent string format - submit feedback at top right");
}
}
useragent: "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) QupZilla/1.8.6 Safari/537.21"
results in the following error:
TypeError: 'null' is not an object (evaluating 'e.match(v)[1]')
I realize not every obscure browser can be supported, but perhaps return "unknown" instead of throwing an exception?
But it should be bowser.browser.msie in an npm environment
Hey @ded
We talked about this, a long time ago and i totally respect that your project is written in the code style you like and love.
Unfortunately i'm not able to switch back to your main branch since our build tool is more strict about the javascript syntax it can handle, and breaks when trying to minify bowser.
If you're ok with it, i will try to tighten up your jshint config until i pass our pipeline and then open a PR. However if that's not an option for you i'll just stick to our fork.
kind regards, Hannes.
Latest Safari on IOS 8 is not supported currently with bower
Here is the new user agent to add:
Mozilla/5.0 (ipad; CPU OS 8_0 like Mac OS X) AppleWebKit/600.1.4
(KHTML, like Gecko) Version/8.0 Mobile/12A365 Safari/600.1.4
Thanks in advance,
Using the existing tests, I can't figure out a way to detect mobile chrome. The user agent string contains "Mobile," which might be a good test to add.
Hi,
with browser of http://www.free.fr/adsl/freebox-revolution.html, we can see
"Mozilla/5.0 (Freebox; Linux i686) AppleWebKit/538.1 (KHTML, like Gecko) Navigateur web/1.0 Safari/538.1"
Running bower install --save bowser
yields:
bower bowser#* not-cached git://github.com/ded/bowser.git#*
bower bowser#* resolve git://github.com/ded/bowser.git#*
bower bowser#* download https://github.com/ded/bowser/archive/v0.7.2.tar.gz
bower bowser#* extract archive.tar.gz
bower bowser#* deprecated Package bowser is using the deprecated component.json
bower bowser#* mismatch Version declared in the json (0.7.1) is different than the resolved one (0.7.2)
bower bowser#* invalid-meta bowser is missing "ignore" entry in bower.json
bower bowser#* resolved git://github.com/ded/bowser.git#0.7.2
bower bowser#~0.7.2 install bowser#0.7.2
bowser#0.7.2 vendor\bowser
For some commercial projects it is important to know licenses of all libraries that are included into distribution. What is the license of this product?
I tryed the Graded Browser Support in chrome 11.0.696.68 osx and it returns to me bowser.x not bowser.a probably is failing the (bowser.chrome && bowser.version >= 8) probably because the string nature of bowser.versione probably it should be split until the . and taken just the major version number.
Thanks bye
It would be usefull to get browser name from the bowser structure.
I would for example like to use this lib for detecting browser name for my logs.
So what about adding 'browserName' parameter to the result structure like this?:
if (ie) return {
msie: t
, version: ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]
, browserName: 'IE'
}
if (opera) return {
opera: t
, version: ua.match(webkitVersion) ? ua.match(webkitVersion)[1] : ua.match(/opr\/(\d+(\.\d+)?)/i)[1]
, browserName: 'Opera'
}
sleipnir
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 Sleipnir/6.1.4
bowser.chrome // true
bowser.version // 39
bowser.a // true
k-meleon
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20140105 Firefox/24.0 K-Meleon/74.0
bowser.firefox // true
bowser.version // 24
bowser.a // true
greenbrowser
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; GreenBrowser)
bowser.msie // true
bowser.version // 7
bowser.c // true
deepnet
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2)
bowser.msie // true
bowser.version // 7
bowser.c // true
slimbrowser
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
bowser.msie // true
bowser.version // 11
bowser.a // true
Is bowser working as designed?
Basically we don't see how the browser level checks such as bowser.msie
and boswer.firefox
can be trusted at all.
Please add semicolon at the end of minified file because missing semicolon caused javascript error at following place:
!function(e,t){ /* bowser minified code*/})
/*!
* jQuery Migrate - v1.2.1 - 2013-05-08
* https://github.com/jquery/jquery-migrate
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
*/
(function( jQuery, window, undefined ) {...})( jQuery, window );
Hi, for some reasons I'm interested in detecting following browsers,
which are the one used by caniuse.com:
I figured out how to check for the easy ones, but could you help me
to complete the list?
Or maybe it's not possible?
(and below, I'm not sure at all)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.