PDA friendly website redirection?
say if someone went to www.hello.com on a PDA. Is there a snippet of PHP (or perhaps javascript?) code that will identify the PDA device (or pocket internet explorer) and automatically redirect the user to a PDA friendly website (www.pda.hello.com?)
Back to top |
|||||
That's a good question. The easiest way would be to deliver the CSS as media type 'handheld', but I don't know if any handheld devices support the media type 'handheld'.
Some opera browsers might support that media type, but I don't know which is the first Opera version that might support it You can read more about this question at Opera Mobile Device Page, the following information is located here :: Code :: <!-- This stylesheet will only be displayed on PC screens -->
<link rel="stylesheet" href="desktop.css" media="screen"> <!-- This stylesheet will only be used for printing --> <link rel="stylesheet" href="printout.css" media="print"> <!-- This stylesheet is for slide shows --> <link rel="stylesheet" href="presentation.css" media="projection"> <!-- This stylesheet will be used by devices --> <link rel="stylesheet" href="phone.css" media="handheld"> You could also do browser navigator useragent string testing, which would be overall a better way. Opera is commonly used in Nokia and Ericsson devices as the browser, I'm not sure about the rest. Unfortunately, there isn't a standard way yet for handhelds to identify themselves. The best thing to do is to get the navigator user agents for all the browsers used by the handheld devices, post them here, then we can do a modification of our php browser detection script to add support for PDAs and Mobile/Cellphones. Back to top |
|||||
Mobile Sniffer
Hi Jeff,
I'm looking to do the same thing. Though because Opera for handhelds is the only browser that seems capable of using the "handheld" media link attribute - the best path - and the reason to use your great script - is to dynamically change the "screen" or "all" css to something designed specifically for handhelds only when it detects a mobile phone. So normal, default = ... href="screen.css" media="screen"... When your script detects that the user agent is a mobile device = ... href="handheld.css" media="screen"... So the trick then becomes how do you tell what is a phone and what isn't? Answer I think may be this open source project = wurfl.sourceforge.net It is an exhaustive list of mobile devices and all their attributes in one big xml file: wurfl.sourceforge.net/wurfl.xml They have a device element with a user_agent attribute. Ex: <device user_agent="Nokia2650/1.0 (5.17) Profile/MIDP-1.0 Configuration/CLDC-1.0"... The list is exhaustive so you'd have to streamline it - ie bring just the user agent info into a local db. I'm looking to implement something like this and am just now looking at the best solutions. Thoughts? Back to top |
|||||
Hi Nat, that question has come up before, but got stuck on the back burner.
One reason the script hasn't been updated is that there are such a ridiculously huge number of handheld devices, all of which seem to handle different types of html/css. So the best that could be done realistically would be to assemble a real world list of handheld useragent strings, then simply detect those. One reason this hasn't happened is because the handheld user agents simply will not settle on any one standard syntax. It's really annoying, I don't know why they can't standardize their format, currently it's a tower of Babel in terms of consistency, even within the same product lines of the same brand. Browsers finally, with a few exceptions, have done this. However, with all that said, in fact, verison 5.0, if it ever comes out, will feature a basic hand held detection, from a list of real world user agents we've put together. I'm familiar with the sourceforge list, but, like php's get_browser list, it's absurdly long, and has far too much information on it to be of any real world use in terms of the php browser detection script here. What I'm leaning towards after having thought of this for a while is to simply scan for known common handheld device names, the ones actually being used, I've been collecting a list of the ones visiting this site, if you have more ones pulled from real website stats feel free to post them here, the full user agent string that is. Then I'd probably add another parameter to the main script, like $is_handheld. It's kind of inelegant, but it would be easy to do. That way the script would return the handheld version as the os version, it would attempt to extract the device version number, and it would report it as handheld. Or something like that, I'm not positive exactly what would work best and be simplest. Back to top |
|||||
Parsing Wurfl
Cool. And re: furl - even if you were to parse that xml Wurfl opn source list and make your own list just of it's os's or the available browsers - you think that resulting list would still be too long? Ie, containing a bunch of devices nearly no one uses?
- Nat Back to top |
|||||
Nat, short answer to all your questions: yes.
Those lists are fine for certain applications, but a real world useable browser detection script isn't one of them. Plus I'd have to add an xml parser, which doesn't work very reliably last time I tested it cross platform. Huge pain for pretty much zero gain. When you compare that to just adding a small array of known handheld agents, and looping through it, you can see that the only thing that would be achieved using the massive list would be Radically slowing down the performance of the script, bloating it out a bit more, and making it generally less useful to real world users. I know the handhelds that visit this site, and it's a list about 30 or 40 items long. Again, if you have any real world handheld stats, by useragent, feel free to post them here. You'll soon notice how few there really are. Back to top |
|||||
All times are GMT - 8 Hours
|