Small plugin to detect mobile browser
Usage Frontend:-
alert(SmartPhone.isAndroid());
OR
alert(SmartPhone.isAny());
OR (browserify):
var SmartPhone = require('detect-mobile-browser')(false);
module.exports = (function($) {
$(document).ready(function() {
alert(SmartPhone.isAny());
});
})(jQuery);
Usage Backend:-
Use as an ExpressJS middleware
var mobileBrowser = require('detect-mobile-browser');
...
...
app.use(mobileBrowser());
app.get('/', function (req, res){
...
...
//in req
console.log(req.SmartPhone.isAny());
...
...
//in res locals to use in templates
console.log(res.locals.SmartPhone.isAny());
...
...
});
$ bower install browser-detector --save
$ npm install detect-mobile-browser --save
$ spm install detect-mobile-browser --save
- isAndroid
- isBlackBerry
- isBlackBerryPlayBook
- isBlackBerry10
- isIOS
- isIPhone
- isIPad
- isIPod
- isOpera
- isWindows
- isWindowsMobile
- isWindowsDesktop
- isFireFox
- isNexus
- isKindleFire
- isPalm
- isAny