iphone detection app

0 views
Skip to first unread message

/>eathwish

unread,
Nov 6, 2008, 8:26:12 PM11/6/08
to iWebKit
I used Andy Moore's detection script so that if visitor's were viewing
my site from a desktop they would be directed to my main web site & if
they were on a pda or cell phone they would be directed to my pda web
site. It also has a line that will direct to an iPhone site.

It doesn't seem to work with the 3G iPhones. It just directs them to
my pda site. Does anyone know of another detection script that will
differentiate not only b/w desktop & iPhones but also a 3rd detection
for other pdas/cell phones?

I know about DeviceAtlas but I would prefer a free or at least cheaper
option as it was pretty expensive last time I checked.

Winterboard

unread,
Nov 7, 2008, 8:26:14 AM11/7/08
to iWebKit
can't you just use javascript or any php alternative?

<script language=javascript>
<!--
if((navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/iPod/i)))
{
location.href='YOURMOBILESITE.html';
}
-->
</script>

than all iphones and only iphone will be redirected to the page you
choose

/>eathwish

unread,
Nov 8, 2008, 8:00:29 AM11/8/08
to iWebKit
Thanks. I didn't know it was that easy in java. Can you reccomend a
php alternative as the script I use already is in php.
> > option as it was pretty expensive last time I checked.- Hide quoted text -
>
> - Show quoted text -

/>eathwish

unread,
Nov 8, 2008, 12:08:40 PM11/8/08
to iWebKit
Ok. I found this PHP code... haven't tried it yet. I'll post if it
works in case anyone else is interested:

function detectiPhone($query){
$container = $_SERVER[’HTTP_USER_AGENT’];

$useragents = array (
“iPhone”,”iPod”);
$this->iphone = false;
foreach ( $useragents as $useragent ) {
if (eregi($useragent,$container)){
$this->iphone = true;
}
}
if($this->iphone){
echo (”This is a iphone or iphone touch - do something like redirect
here”);
}else{
echo (”You are not on an iPhone or iPod touch”);
}
}

?>
> > - Show quoted text -- Hide quoted text -

Winterboard

unread,
Nov 9, 2008, 6:15:58 PM11/9/08
to iWebKit
And does it work??

goofy166

unread,
Dec 16, 2008, 1:14:08 AM12/16/08
to iWebKit
This code works great, thanks!!!!!!
Reply all
Reply to author
Forward
0 new messages