gabceb / jquery-browser-plugin Goto Github PK
View Code? Open in Web Editor NEWA jQuery plugin for browser detection
License: Other
A jQuery plugin for browser detection
License: Other
@gabceb The code is very inconsistently indented. The JS uses tab and space mixture, as does the tests, but the CoffeeScript uses spaces only. Most JS style guides recommend two space soft tab indentation. I noticed this while working on #24, and it made it a bit hard to edit. I don't know if you want to change it, but I thought I wanted to mention it.
$.browser.msie
"Unable to get value of the property 'msie': object is null or undefined"
I get the above in IE9.
The anonymous module registration is not allowed in require.js and causes the error message
"Mismatched anonymous define() modules ..."
Can easily be solved by naming the module:
define(['jquery'], function ($) {
define('jquery-browser',['jquery'], function ($) {
Since you have this published to npm, it would be awesome if it was commonjs-compatible, which it currently is not. #18 mentions that umd is a good way to solve this problem, it would work for cjs as well. Trying to use this in a project that launches shortly, happy to pitch in with pull requests etc -- are you ok with this? If not I can fork, but I'd rather work with you to make it happen on the original π
Hello,
how can i check an Windows Tablet or Rouch Display with this Plugin?
Hey, i did a check on the default Android browser. You're script is giving me the following feedback:
["safari:true","version:4.0","versionNumber:4","android:true","webkit:true","name:safari","platform:android"]
On whatbrowser.org the browser is stated as "Android 4"-Browser.
Maybe you could implement the regex from the given website.
When this happens, it just shows up with an empty tooltip, is this supposed to happen, shouldn't it not do this?
Thanks
Microsoft announced that Internet Explorer 11 in the upcoming Windows Phone 8.1 Update will change the user agent (again) and it looks somewhat like this.
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 920) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537 (Ref)
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; 909) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537 (Ref)
Jesus.
The update would take months to get to the consumers, so it is kind of subject to change, hopefully, but unlikely.
Here is a reddit thread if you're interested.
Seems to happen because the link to the file has no image extensions.
I want to remove the coffeescript file and only keep the js and min js files. Would love to hear if there are any objections.
Win10 comes out July 29, and I'm almost sure the new UA is on MSDN.
Please consider making you plugin AMD friendly.
There is an easy and complete way:
https://github.com/umdjs/umd
Thank you!
Hi,
$.browser.versionNumber
set to 12.11
in Opera 12.11
According to the description:
Detect the browser's major version
it should be 12
. Shouldn't it?
Opera's version info:
About Opera
Version information
Version 12.11
Build 1661
Platform Win32
System Windows 7
I think the problem is in parseFloat(matched.version, 10)
(dist/jquery.browser.js:56).
Should be something like this: parseInt( $.browser.version.split(".")[0] )
. Split string and get the first array item - the major version number and convert it to int.
Name: Windows Phone
Modell: NOKIA Lumia 520
Software: Windows Phone 8.1 Update
(OS Version: 8.10.14219.341)
$.browser {
"webkit":true,
"version","537",
"versionNumber":537,
"iphone":true,
"mobile":true,
"name":"webkit",
"platform":"iphone"
}
"Mozilla/5.0 (Mobile; WIndows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 520) like iPhone OS 7_0_3 Mac OS X AppleWebkit/537 (KHTML, like Gecko) Mobile Safari/537"
Thanks (:
You can't copy/paste code from jQuery and change the copyright to yourself. You need to restore the original copyright info or remove this.
The user agent string has changed in IE 11 -- it no longer says 'msie' but "IE11" instead.
Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0)
Can you support
Using $.browser.mozilla returns true in IE11.
Hey,
The old Jquery Browser plugin (http://jquery.thewikies.com/browser/) support a property called browser.name which can be reference to output the name instead of using a bunch if statements - if browser.msie, if etc...
We're migrating to this plugin, and that was the key missing piece.
All I did was add this line to the if ( matched.browser) check:
browser.name = matched.browser;
If you add that in, and in to the min version, that would be great!
According to http://api.jquery.com/jquery.browser/#jQuery-browser-version2, jQuery.browser.version
is supposed to be the browser's rendering engine version number, not the version number of the browser itself.
But on Safari 8 I get 8.0
, while http://code.jquery.com/jquery-migrate-1.2.1.js gives the correct 600.1.22
Some of the variables are not initialized to false:
EXISTING:
if ( browser.android || browser.bb || browser.blackberry || browser.ipad || browser.iphone ||
browser.ipod || browser.kindle || browser.playbook || browser.silk || browser[ "windows phone" ]) {
browser.mobile = true;
}
checking for jQBrowser.mobile on a desktop browser will return 'undefined' instead of false.
FIX:
if ( browser.android || browser.bb || browser.blackberry || browser.ipad || browser.iphone ||
browser.ipod || browser.kindle || browser.playbook || browser.silk || browser[ "windows phone" ]) {
browser.mobile = true;
} else {
browser.mobile = false;
}
The same problem for browser.desktop, browser.safari, browser.xyz
Just a reminder. ;)
Hi,
I have no clue how to fix them, as I never got them working to begin with.
I get error: jquery.browser is undefined
It's a great way to help ensure all contributions are following established standards and are writing valid code.
https://travis-ci.org
@gabceb You would have to do this one as only the owner of a repo can setup Travis.
the following builds a string of browser information, like you might want to do for analytical purposes.
requires jquery-browser-plugin
and jQuery
var browser = '';
($.browser.msie == true) ? browser += ' MSIE /' : false;
($.browser.ipad == true) ? browser += ' ipad /' : false;
($.browser.webkit == true) ? browser += ' webkit /': false;
($.browser.mozilla == true) ? browser += ' mozilla /': false;
var opera = ((!!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) == true) ? browser += ' opera /' : false;
((!!window.chrome && opera === false) == true) ? browser += ' chrome /' : false;
((Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) == true) ? browser += ' safari /' : false;
((/*@cc_on!@*/false || !!document.documentMode) == true) ? browser += ' IE /' : false;
((typeof InstallTrigger !== 'undefined') == true) ? browser += ' FF /' : false;
($.browser.iphone == true) ? browser += ' iphone /' : false;
($.browser["windows phone"] == true) ? browser += ' windows phone /' : false;
($.browser.android == true) ? browser += ' android /' : false;
($.browser.cros == true) ? browser += ' chrome os /' : false;
($.browser.win == true) ? browser += ' windows /' : false;
($.browser.mac == true) ? browser += ' mac /' : false;
($.browser.linux == true) ? browser += ' linux /' : false;
($.browser.desktop == true) ? browser += ' desktop /' : false;
($.browser.mobile == true) ? browser += ' mobile /' : false;
($.browser.version == true) ? browser += $.browser.version : browser +=' Unk /';
alert(browser);
I'm opening this not only for reporting, but also to document what I am seeing. I will update this until I've uncovered everything.
c911970 has broken a number of tests and thus functionality:
Through manual testing, I've found browser.safari
is returning undefined
, and browser.name
is returning "version"
with some UAs.
The script changes in that commit, however, were only applied to the script in the test/src
folder. These issues do not reproduce with the script under dist/
.
I am partly to blame here, as some of the changes made were mine (see the le717-safari-version
branch and #35).
I know this sounds a little weird because the name of this project is jquery-browser-plugin, but it doesn't seem to use jquery for anything. Currently I want to use this plugin to detect the browser before the app launches, therefor I need jquery (I use jquery version 2, old IE versions are not supported) which may break on non supported browsers.
Does it add css support per browser or device?
Or is it plainly detection?
I'm a bit new to jquery but would I have to write the css in the script then or assign new classes?
Test cases for Android and Opera are missing.
The latest release is tagged v0.05, but the previous v0.0.4. This makes installing your plugin with bower more difficult. Could you include a second dot in the next release tag?
Thanks
seems like quite a while since git has been tagged with the latest version.
are you able to do a bump so i can remove the git repo address from my bower.json?
Is it possible with this plugin?
well you have nicely developed plugin , I want to test if browser is Nokia Lumia's IEMobile browser or not !!!
Figure out how to test using casperj and a local html and js file. Consider using https://github.com/yohanboniface/casperserver
Would you consider uploading this to npm? I've been looking around for a jQuery plugin like this after learning $.browser
was removed and writing code last night to parse to user-agent myself. Posting to npm is a great way to have others find this wonderful script and keep it up-to-date.
I have a problem to detect version of older Firefox, for example:
Mozilla/5.0 (Windows NT 10.0; WOW64) Gecko/20100101 Firefox/40.0
I see that Mozilla made some changes:
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
But I am sure, that it worked in older version of jquery.browser plugin
Is this possible with this plugin? I want to know if a user is on a webview (for example if he opens a page link in facebook)
I am running Safari 7.0 on OSX 10.9, and the version number is incorrectly detected. I have been told this also happens on Safari 6.05.
The cause seems to be that the library is detecting the webkit version, rather than the Safari version. Below is my current user agent.
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71
The detected browser version here is 537.71, rather than the expected 7.0.
I have tried fixing this myself, but have only come up with a rudimentary workaround as I am not too slick with regex. I added a line to the match regex which detects Safari:
var match = /(opr)[\/]([\w.]+)/.exec( ua ) ||
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(safari)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf('trident') >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
Then after the matching, I have added this simple if statement to check for Safari, and do another regex to determine the version.
if (match[1] === 'safari') {
match[2] = /(version)[ \/]([\w.]+)/.exec( ua )[2];
}
I'm sure there is a neater way to do this, but for now this does work.
It's pretty standard for a commonly used package to have a license and attribution (source) at the top of the file. I need this, as I literally use hundreds of libraries like this, and I cannot keep track of where they all are.
It would be a lot better for us to be able to quickly identify the license and plugin source than remembering this website url.
thanks,
Kevin
In Chrome OS, I canβt find any platform value.
please check it.
userAgent is as follows
Mozilla/5.0 (X11; CrOS i686 14.811.2011)
AppleWebKit/535.1 (KHTML, like Gecko)
Chrome/14.0.834.0 Safari/535.1
Looks like there has been some changes in the IE 11 Edge User agent string. This causes jQuery browser to interpret IE 11 Edge as Chrome 36.
Here's some info on the topic.
http://msdn.microsoft.com/en-us/library/ie/hh869301%28v=vs.85%29.aspx
Hi!
The tag 0.05
in the repository break some semver version detection.
By exemple: https://www.versioneye.com/javascript/gabceb:jquery.browser/0.0.6
You can see the version 0.05
is seen as the last version instead of the 0.0.6
.
More, the tag 0.0.5
exists too and is not the same as 0.05
.
Is this tag an error or does it mean something particular ?
Is it possible to remove this tag ?
Issue in Jquery browser plugin.
SCRIPT5007: Unable to get value of the property 'msie': object is null or undefined
Beginning from version 15, Opera moved from own Presto engine to WebKit/Blink, changing UserAgent as following:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.20 Safari/537.36 OPR/15.0.1147.18
So you should probably detect OPR/...
substring for newer versions of Opera.
I'm trying to do it myself, sorry for inssue.
You have an error in the following condition (detecting IE11):
ua.indexOf("trident") || ...
If "trident"
substring is not found, ua.indexOf("trident")
returns -1
, which is casted to true
.
(Also, if "trident"
substring is on first position, indexOf
returns 0
, which is casted to false
)
So, the correct condition should be:
ua.indexOf("trident") != -1 || ...
or:
ua.indexOf("trident") >= 0 || ...
We use assetic inside of Symfony to pack multiple JavaScript files into a single one. This process doesn't alter the individual files' content, but appends each one into a single file (minimizing http downloads).
The Problem is that jquery.browser.min.js
is missing a trailing semicolon, which causes JavaScript errors when jquery.browser.min.js
is not the last entry in the packed js file. Just adding the ;
at the end of the minified jquery.browser.min.js
solves the problem and enables us to pack it together with other JS files.
Thanks for a great package.
Can you add bower support?
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.