How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site



How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site
 (397) GoDaddy.com .MOBI Domains!
How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site
Post Description:
Post Tags: how, to, detect, mobile, browsers, wireless, cellphone, users, visiting, your, site
This Post Has Been Viewed 1155 Times Since Fri Apr 04, 2008 7:33 pm Posted By hostman with 1 replies
How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site
now a days you can put wallpapers anywhere, its not just for desktops anymore
its for laptops, pda's, cellphones, smart phones etc..

so there will come a time when you will have to provide content for wurl users

so just how can you detect if a user is using a cell phone when they visit your site.

there are a number of way, the easiest i know how is to do it server side

with php you can do that

php is very powerful programming language that lets you do alot of things for your website

so often i used this function or class to detect if a user visiting my site is coming from a mobile device or not

<?php

function checkmobile(){

if(isset($_SERVER["HTTP_X_WAP_PROFILE"])) return true;

if(preg_match("/wap.|.wap/i",$_SERVER["HTTP_ACCEPT"])) return true;

if(isset($_SERVER["HTTP_USER_AGENT"])){

$uamatches = array("midp", "j2me", "avant", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows ce", "mmp/", "blackberry", "mib/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up.b", "audio", "SIE-", "SEC-", "samsung", "HTC", "mot-", "mitsu", "sagem", "sony", "alcatel", "lg", "eric", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "dddi", "moto");

foreach($uamatches as $uastring){
if(preg_match("/".$uastring."/i",$_SERVER["HTTP_USER_AGENT"])) return true;
}

}
return false;
}

if(checkmobile()){
echo '
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<title>Google</title>
</head>
<body>
Hello Mobile User, Welcome to Wallpaperama.com
</body>

</html>

';
}else{
echo 'NOT you are using a mobile phone';
}

?>

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Detect Mobile Browsers Wireless Cellphone Users Visiting Your Site




:: 1 :: #62051 - Reply By david On Wed Jul 16, 2008 4:48 pm
to actually detect what device is browsing your site, or requesting the mobile content, you can use handsetdetection which actually tells you the screen size of the device and other device characteristics