_____________________________________________
Script #1
In this script, change the $location attribute to the page you want your users to see if they are using one of the mobile devices listed in the if(stristr.. string.
____________________________________________________
Script #2
This is a simpler script to detect Windows CE browsers (although you can detect any browser with this script.) Simply change the window.location URL to your mobile friendly site.
____________________________________________________
In both of these cases, I'm redirecting the site to the mobile version of this site- http://www.2mlearn.mobi/
I will be adding this script to http://www.mlearning-world.com/ in the next few days
to help all our visitors with mobile devices.
mlearning m-learning mobile-learning mobile+learning podcasting iphone apple web+2.0 learing+2.0 eLearning
7 comments:
Hey Matthew; good, useful post, but I'm wondering about the purpose of the second conditional in the first set of code. Couldn't you optimise it thus?
if (stristr($ua, "Windows CE") or stristr($ua, "AvantGo") or stristr($ua, "Mazingo") or stristr($ua, "Mobile") or stristr($ua, "T68") or stristr($ua, "Syncalot") or stristr($ua, "Blazer"))
{ $location='http://winksite.com/mlearning/teach';
header('Location: '.$location);
}
This would remove the second conditional and make it a bit simpler.
Cheers,
L.
http://mlearning.edublogs.org
Good catch Leonard. I will test it both ways with several devices to see if the DeviceType conditional is needed.
great script. I'm using
(script language='JavaScript' type="text/JavaScript">
var isCE = navigator.appVersion.indexOf("Windows CE")>0;
if (isCE)
{
window.location.href="http://m.fordpiano.com";
}
(/script)
w/ minor adjustments
How do you go about modifying the script so that it will detect other devices such as a black berry, iphone, etc. Thanks!
another alternative would be to use a service like handsetdetection.com
Nice posting... easy to download
i like this articlee
I've created a similar set of scripts in an article I wrote entitled Mobile Browser Detection and Redirection with PHP... Here's a link: http://www.mlynn.org/2010/06/mobile-device-detection-and-redirection-with-php/
There is a link for downloading the example scripts.
Enjoy!
Mike
Post a Comment