PDA

View Full Version : Code to recognize devices (mobile or PDA)


essjay_d12
08-03-2005, 05:44 AM
Hi,

Does anyone know how I can get a html site to have a link to a certain site - though if they click on that link and are a mobile device they get sent to a different address such as the mobiles version of our site - rather than them having to type in the address all the time.

Google seems to do it, but I cannot work out how?

Anyone know?

Cheers

Simon

Horus_Kol
08-03-2005, 05:48 AM
I think google does it by checking the agent information sent in the request from the user - at least, that would be how I do it...
that would actually require knowledge of how the various agents (browsers) identify themselves, along with a server side script to distinguish them and send the correct content.

You could do this in javascript, but you would be transmitting more information than necessary because you would have to send all versions of the page in order for it to be able to select the correct on at the client - and if you are browsing with a mobile or something, then bandwidth is a major factor...

essjay_d12
08-03-2005, 06:16 AM
What would you advise then?

What is my best option?

Horus_Kol
08-03-2005, 06:47 AM
use a server side script (such as ASP or PHP) to get the agent information from the request, and then deliver the page as designed for that agent...

the server side script for this needn't be complex - pretty much an IF...THEN...ELSE construct.