auto-redirect for PDAs
I have a pocket pc phone - and I noticed some time ago that Google auto redirects me (when I'm on my phone) to the pda version of the page.
Being a lover of all things scripty - I've been looking for a way to do that too… Not that I've had a huge request for it - but just for the cool/why-not factor.
Every now and then I'll search around for it - but I still haven't found anything conclusive. I did however, come across this link this morning. which had the following code:
<script>
if (navigator.userAgent.indexOf("Windows CE") != -1)
{window.location='mindex.php'}
</script>
Even on that link, the poster said that it only works with pocket pc.
If anyone else has any ideas - I'd love to hear them!
Some generic browser sniffing can be found here: moock, dynamic drive, codehouse, webreference (but none of those focus on PDAs)
(and it's a little weird that almost a year ago today I was thinking about browser sniffing too… history repeats itself, I guess)
update: Doc had the answer - see the comments of this post! ![]()
March 16th, 2004 at 1:08 pm
I actually use my .htaccess to accomplish this quite well. A while back I wrote an article on how I accomplished this: http://www.seadoc.net/sd/archives/individual/2003/03/20030315-htaccess_tricks_browser_sniffing.php
The system has been refined a little since then and if you would like my current code just e-mail me and I'll be happy to share.
Also you can look at this thread: http://www.pocketpcthoughts.com/forums/viewtopic.php?p=140485
for some other ideas and ways to accomplish this.
March 16th, 2004 at 2:13 pm
Since I got swamped with e-mails, I'll just post the most current PDA Browser code I am using here. Not really many changes, just cleaned up a little.
Remember, you must have Mod_ReWrite enabled and RewriteEngine ON listed at the top in your .htaccess for this code to work.
NOTE: If anyone has any other PDA UserAgents, Plese e-mail me so I can keep this code up to date.
#browser redirects For PDA Based Browsers
RewriteCond %{HTTP_USER_AGENT} "Windows CE" [NC,OR] #Windows CE and Pocket PC
RewriteCond %{HTTP_USER_AGENT} "NetFront" [NC,OR] #PalmSource WebBrowser 2.0
RewriteCond %{HTTP_USER_AGENT} "Palm OS" [NC,OR] #Eudora Web Browser for Palm
RewriteCond %{HTTP_USER_AGENT} "Blazer" [NC,OR] #Handspring Blazer Browser
RewriteCond %{HTTP_USER_AGENT} "Elaine" [NC,OR] #RIM Devices
RewriteCond %{HTTP_USER_AGENT} "^WAP.*$" [NC,OR] #WAP Browsers
RewriteCond %{HTTP_USER_AGENT} "Plucker" [NC,OR] #Plucker Offline download client
RewriteCond %{HTTP_USER_AGENT} "AvantGo" [NC] #AvantGo Service
RewriteRule ^index\.php http://www.yourdomain.net/pda.php [L,R]
March 16th, 2004 at 2:21 pm
Thanks Doc!! You rock!!
hey, that rhymes!
March 16th, 2004 at 4:13 pm
Yes, that's a truly elegant solution (why do us, geeks, love that .htaccess file so much? :D). However if you're webhost doesn't support .htaccess rewriting for whatever reason and you're using PHP pages here's a snippet of code that should work. You can include it at the begining of your pages BEFORE any output is generated otherwise it won't work.
<?
$pda_agents = Array('Windows CE', 'NetFront', 'Palm OS', 'Blazer', 'Elaine', 'WAP', 'Plucker', 'AvantGo');
$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
foreach($pda_agents as $pda_agent) {
$found = stristr($http_user_agent, $pda_agent);
if($found) header('Location: pda.php');
}
?>
(I shamelesly stole Doc's user agent signatures, please don't shoot me! :D)
March 16th, 2004 at 5:14 pm
Really. My life turned quite boring… My schedule turned upside down: Sleeping during the day, awake through the night. As a direct result I'm obviously not attending school as I should. I received my DMS3 modchip but when I saw…
October 15th, 2004 at 11:30 am
Anyone know of a script that will redirect for wap phones please email me and let me know, Mike
June 2nd, 2005 at 1:42 am
These postings are probably a bit out of date. But for anyone else that might stumble across this like I did hereis some more info on mobile browser agent ids
Mobile ID's