JavaScript Cover Image
JavaScript Profile Picture
3 Members

The following JavaScript code detects whether the visitor is using a mobile device and whether it's a 32-bit or 64-bit OS that is used:

// DETECT MOBILE DEVICE
PF = navigator.platform;
UA = navigator.userAgent;
DEVICE = navigator.userAgent + " " + navigator.platform;
MOBILE = /PHONE|MOBILE|TABLET|IPOD|IPAD|BLACKBERRY|LUMIA|ANDROID|WEBOS|PLAYBOOK|BB10|MINI|CRMO|OPERA MINI|OPERA MOBI|PALM|WINDOWS CE|XOOM|SCH-I800|KINDLE/i.test(DEVICE) | 0;

// DETECT 64-BIT CPU
X64 = /X86_64|X86-64|WIN64|X64|AMD64|WOW64|IA64|SPARC64|PPC64/i.test(DEVICE) | 0;

I'm thinking about expanding this group a bit. One of the languages that very closely resembles JavaScript is Perl. But while JavaScript mostly runs inside browsers, Perl runs mostly on Linux and web servers. The similarities are just too many to number.

Easily test whether your visitor is using a handheld device :

PF = navigator.platform; if (PF == null) PF = "Android";
UA = navigator.userAgent;
DEVICE = navigator.userAgent + " " + navigator.platform;
MOBILE = /PHONE|MOBILE|TABLET|IPOD|IPAD|BLACKBERRY|LUMIA|ANDROID|WEBOS|PLAYBOOK|BB10|MINI|CRMO|OPERA MINI|OPERA MOBI|PALM|WINDOWS CE|XOOM|SCH-I800|KINDLE/i.test(DEVICE) | 0;


About

This group is for JavaScript programmers to share code, ask questions, and discuss JavaScript and anything related to it. Welcome, and have fun! Keywords : web apps, mobile apps, website design, learning computer programming, Node.JS, Frameworks, Libraries, code optimization, web browsers, Linux, server-side, client-side, web development, HTA