Displaying Content to Specific Browsers
Problem
I need to display content to specific browsers in order to get around some rendering issues.
Solution
Use the fb:user-agent
tag. The simplest form is:
<fb:user-agent includes="ie 6">
Your browser has lots of rendering issues!
</fb:user-agent>Discussion
You might want to use this tag for reasons other than browser idiosyncrasies, but that’s likely to be the main use. Every browser, crawler, indexer, etc. has a different “user-agent” string that represents the browser and company who make it. A few popular examples are given in Table 6-4.
Table 6-4. Some fun user-agent examples
User agent | Description |
|---|---|
Googlebot/2.1 (http://www.googlebot.com/bot.html) | Google crawler |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5 | Mozilla Firefox 3.0b5 on an Intel-based Mac running Mac OS X 10.4 |
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; bgft) | Microsoft Internet Explorer 7 on Windows XP |
Opera/9.00 (Windows NT 5.1; U; de) | Opera 9 on Windows NT, running in German |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; en-ca) AppleWebKit/525.13 (KHTML, like Gecko) version/3.1 Safari/525.13 | Safari 3.1 on an Intel-based Mac running Mac OS X 10.5.2 |
For a full list of user agents, see the excellent http://www.user-agents.org, maintained by Andreas Staeding. You can also quickly find out the user agent for your browser by visiting http://www.whatsmyuseragent.com, which includes an excellent resource page about how to fake different ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access