homepage Welcome to WebmasterWorld Guest from 54.211.73.232
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / The Macintosh Webmaster
Forum Library, Charter, Moderators: travelin cat

The Macintosh Webmaster Forum

    
Ad code which recognises Mac OS
jdvjdv

5+ Year Member



 
Msg#: 4009903 posted 7:40 am on Oct 20, 2009 (gmt 0)

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

 

swa66

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



 
Msg#: 4009903 posted 8:22 am on Oct 20, 2009 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / The Macintosh Webmaster
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved