There are so many mobile browsers available today that it would be difficult to specify each one. Unfortunately, if you wanted to detect the user browser through javascript you would have to explicitly specify each browser/mobile device and which action to perform if that mobile device is detected. Fortunately enough this can be significantly simplified using some simple PHP code as shown below:

$container = $_SERVER['HTTP_USER_AGENT'];
	$mobile = false;
	$useragents = array (
		'blackberry',
		'slurp',
		'mspie',
		'pocket',
		'opera mini',
		'Series60',
		'S60',
		'iPhone',
		'iPad',
		'iPod',
		'Android'
	);
	
	foreach ( $useragents as $useragent ) {
		if(stripos($container, $useragent)) {
			$mobile = true;
		}
	}
	
	if($mobile){

	} else {
	
	}

Using the code above you can simply echo out specific HTML or javascript code based on what type of device a user is on.


Login

or Sign Up

Sign Up

or Login
×
tnylea
Cheers Friend!

I'm Tony, the creator of this site. I'm trying to increase my twitter following. Want to follow me?

Follow @tnylea If not, no worries :)