Return to Snippet

Revision: 16476
at August 5, 2009 20:31 by robksawyer


Initial Code
function Client() {
}

Client.prototype.mobileClients = [
	"midp",
	"240x320",
	"blackberry",
	"netfront",
	"nokia",
	"panasonic",
	"portalmmm",
	"sharp",
	"sie-",
	"sonyericsson",
	"symbian",
	"windows ce",
	"benq",
	"mda",
	"mot-",
	"opera mini",
	"philips",
	"pocket pc",
	"sagem",
	"samsung",
	"sda",
	"sgh-",
	"vodafone",
	"xda",
	"iphone",
	"android"
];

Client.prototype.isMobileClient = function(userAgent)
{
	userAgent=userAgent.toLowerCase();
	for (var i in this.mobileClients) {
		if (userAgent.indexOf(this.mobileClients[i]) != -1) {
			return true;
		}
	}
    return false;
}

var client = new Client();
client.isMobileClient(navigator.userAgent);

Initial URL
http://www.phpdevblog.net/2009/01/detecting-mobile-devices.html

Initial Description


Initial Title
Client-side mobile device detection

Initial Tags
phone, mobile, iphone

Initial Language
JavaScript