smali-kazmi / detect-mobile-browser Goto Github PK
View Code? Open in Web Editor NEWIt is a very simple & small javascript lib to detect all major modern mobile browsers in both backend & frontend
It is a very simple & small javascript lib to detect all major modern mobile browsers in both backend & frontend
I think you should have chosen "Mobile" as tablets are not phones, other than that this is great :).
Also i find it odd that you are using browser-detector
as the bower name, and the entry point is named detect-browser
and your namespace is SmartPhone
.
We should standardize all of this ;).
Hi @smali-kazmi ,
I tried to require it as var mobileBrowser = require( 'detect-browser');
, it was giving me error as Cannot find module 'detect-browser'
, but when I tried var mobileBrowser = require( path.join(global.config.root, '/node_modules/detect-mobile-browser/detect-browser'));
, it worked fine.
Hey,
I tested this simply:
<script type="text/javascript" src="js/detect-mobile.js"></script>
<script type="text/javascript">
console.log(SmartPhone.isAny());
</script>
Result:
Cannot read property "match" of null on line 28 in detect-mobile.js
It seems that the "userAgent"-property within the SmartPhone-object is null.
The reason is, that (tested under webkit & firefox) console.log(typeof window);
prints object
and not function
, and therefore the user Agent will not be set. I don't know why this bug has not been detected before, but the solution is simple:
On line 111, change:
if(typeof window === 'function') {
to:
if(typeof window === 'function' || typeof window === 'object') {
Why is this not working?..sorry if i'm misunderstanding something
<!doctype html>
Hello there,
another strange bug seems to appear: SmartPhone.isAny()
says true when opening the web page with Firefox on Windows 10 Desktop.
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0
... matches of course the check of return this.getUserAgent().match(/Firefox/i);
I don't know how to detect the mobile Firefox, but a solution could be using a mix of platform and user agent detection like:
return this.getUserAgent().match(/Firefox/i) && navigator.platform.match(/android/i);
This would work for all phones except the FirefoxOS as Firefox is currently only deployed to android. But in cause of my lack of experience with mobile firefox I don't commit this as a pull request and I'm only suggesting it here. Also, this solution would break the Node.JS-support.
Greetings
Thanks for this nice app. There is a very small error in README.md line 16:
alert(SmartPhone.isAndriod());
Should be:
alert(SmartPhone.isAndroid());
(Andriod -> Android).
Not too important but it may happen that someone will copy/paste it (as myself) and will knock his head why it doesn't work!
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.