NODEJS detect tablet, ipad, iphone, android and blackberry nodejs - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

how to detect tablet, iPad, iPhone, Android and Blackberry using nodejs ?


 907

NODEJS


4

// you must install "npm install express-useragent --save"
// insert the following code into test.js

var express = require('express');

var app = express(),

useragent = require('express-useragent');

app.get('/', function(req, res){

var source = req.headers['user-agent'];

var info = useragent.parse(source);
var device = "";

if (info['isDesktop'] == true) {device = "desktop"}

else if (info['isTablet'] == true) {device = "tablet"}

else if (info['isiPad'] == true) {device = "iPad"}

else if (info['isiPod'] == true) {device = "iPod"}

else if (info['isiPhone'] == true) {device = "iPhone"}

else if (info['isAndroid'] == true) {device = "iAndroid"}

else if (info['isBlackberry'] == true) {device = "Blackberry"}

else {device = "something else"}

res.send(device)
})

app.listen(3000);
console.log("Listening to Port 3000");

// type "node test.js" in command prompt
// then put this url "http://localhost:3000/" into any browser


By     Created   
The power of the user (%)
63%



The most helpful NODEJS solutions

get user ipget user ipNODEJS

Click to see more ...

  4.7K     1.7K

how to get client netmask using node.js ?how to get client netmask using node.js ?NODEJS

Click to see more ...

  2.3K     558

How to get client machine name and computer name with node.js?How to get client machine name and computer name with node.js?NODEJS

Click to see more ...

  2.2K     423

how to get client local ip address using node.js ?how to get client local ip address using node.js ?NODEJS

Click to see more ...

  1.2K     311

How to get client ip address using node.jsHow to get client ip address using node.jsNODEJS

Click to see more ...

  913     268

How to combine node.js and jquery ?How to combine node.js and jquery ?NODEJS

Click to see more ...

  675     247

how to detect tablet, iPad, iPhone, Android and Blackberry using nodejs ?how to detect tablet, iPad, iPhone, Android and Blackberry using nodejs ?NODEJS

Click to see more ...

  907     138

get real user ip address using node.js?get real user ip address using node.js?NODEJS

Click to see more ...

  380     123

get client region using node.js ?get client region using node.js ?NODEJS

Click to see more ...

  288     118

how to update a record in mysql using node.js ?how to update a record in mysql using node.js ?NODEJS

Click to see more ...

  283     115