Welcome to WebmasterWorld Guest from 54.166.102.61

Forum Moderators: travelin cat

Ad code which recognises Mac OS

   
7:40 am on Oct 20, 2009 (gmt 0)

10+ Year Member



We're looking for code which will enable recognise a Mac operating system (presumably via the GET + browser headers) and then enable the display of a certain piece of code as opposed to the other(s).

We've not had any luck finding working examples via google, does anyone have a suggestion?

Thanks

8:22 am on Oct 20, 2009 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The user agent string for popular browsers should be easily obtained and you can then deliver different content based on that depending on OS.

Check your logs for the user agent strings.

e.g.:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)"

That's a windows based firefox (tainted by the .net plugin)

e.g.:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3

That's the same version of Firefox on an intel mac and PowerPC mac respectively.

e.g.:
Safari windows:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3
Safari mac:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9

e.g.:
Opera 10 windows:
Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.00
Opera 10 mac:
Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00

e.g.:
Chrome on windows:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0
Chromium on mac:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.222.5 Safari/532.2

From the sample above it feels safe to say that if you find
"Mozilla/5.0 (Macintosh;" at the beginning of the user agent string that you're dealing with a mac user. Since that excludes browsers that do not claim to be netscape (a trend started by MSFT during the browser wars),

Just match on "(Macintosh;" being part of the user agent string.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month