Forum Moderators: coopster

Message Too Old, No Replies

need code to display different messages based on browser or OS

         

hal12b

1:50 pm on Aug 19, 2010 (gmt 0)

10+ Year Member



I am working on a few web sites and want to display certain information to users using mobile devices and everything else to people who access the site traditionally through a desktop/laptop (they'd be using IE, FireFox, Safari, etc..). The mobile users will be using Droid, and Ipod/Iphone/Ipad, and maybe blackberry and other mobile devices. My pages are in PHP. Thanks for any help.

lammert

3:04 pm on Aug 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The User Agent string which contains information about the used browser and OS can be accessed in PHP in the variable $_SERVER['HTTP_USER_AGENT']. Scanning this string with regular expressions which match certain browsers should do the trick.

hal12b

3:42 pm on Aug 19, 2010 (gmt 0)

10+ Year Member



Will this tell me if they are using Safari on an Ipod/Iphone/Ipad or Safari via desktop/laptop?

hal12b

5:10 pm on Aug 19, 2010 (gmt 0)

10+ Year Member



Maybe I should be trying to detect browser pixel size instead? Would it be safe to assume anybody with less than 400 pixels is on a mobile device, maybe except for an iPad?

rocknbil

6:14 pm on Aug 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to use Javascript to access screen resolution. You will find what you need in user agents as mentioned.

Anyango

10:39 am on Aug 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As they said, User-agent string will tell you all the information required, then you can see a list of all user agent strings for comparison.