views:

75

answers:

1

I want to create a website that can be visited by type of browsing device and when the user visits the site on different devices (iPad, iPhone, Netbook, PC) they immediately see the version of the site optimized for them instead of having to go to m.example.com . I know that you can specify html to print etc. Is there a type for device sizes and types (multitouch vs. mouse based)?

+5  A: 

Yes, your webserver can examine the USER_AGENT string that comes with every request. Each of thee devices you mention will send a string uniquely identifying what it is. I'm on a mobile device now, and don't have references, but you'll find what you need if you google 'useragent'.

Once you know the device, you can easily send device-specific HTML, stylesheets and/or JavaScript to tailor the experience for each device.

Good luck!

mkoistinen
Great! Thanks, I thought there was a way.
chromedude
Be aware that USER_AGENT strings can be faked or suppressed, and that browsers intentionally send strings that contain text from other browsers -- such as, for example, the IE8 User Agent string which starts with "Mozilla/5.0". Depending on "browser sniffing" is brittle.
Stephen P
@Stephen P ok thanks for the heads up.
chromedude