h1

Detectando smartphones com JavaScript

03/04/2011

Detectando um iPhone/iPod touch/iPad

function DetectIphoneOrIpod()
{
if (DetectIphone())
return true;
else if (DetectIpod())
return true;
else
return false;
}

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i))) {
if (document.cookie.indexOf(“iphone_redirect=false”) == -1) {
window.location = “http://example.com/”;
}
}

Detectando um Symbian

function DetectS60OssBrowser()
{
if (uagent.search(engineWebKit) > -1)
{
if ((uagent.search(deviceS60) > -1 ||
uagent.search(deviceSymbian) > -1))
return true;
else
return false;
}
else
return false;
}

Detectando um Android (WebKit)

function DetectAndroidWebKit()
{
if (DetectAndroid())
{
if (DetectWebkit())
return true;
else
return false;
}
else
return false;
}

Detectando um Windows Mobile (Não Windows Phone 7)

function DetectWindowsMobile()
{
if (uagent.search(deviceWinMob) > -1)
return true;
else
return false;
}

Detectando um BlackBerry

function DetectBlackBerry()
{
if (uagent.search(deviceBB) > -1)
return true;
else
return false;
}

Seguir

Obtenha todo post novo entregue na sua caixa de entrada.