Documentation >> Conditionals >> Web Server >> userAgent
Conditional Macro: userAgent
Operators:
- == (equal to)
- != (not equal to)
- beginsWith
- endsWith
- contains
Usage Notes
- Tests the "User-Agent" field, or the identity of the software that requested the web page, and compares it with the |conditional value| on the right of the |conditional operator|.
- The User-Agent is the software running on the remote computer that requested the page, such as a web browser or a site indexing 'robot'.
- There are literally thousands of different possible UserAgents. For example, every version of every browser uses a different "User-Agent" when requesting a page from a web server.
- Some example User-Agents:
- Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC)
- FAST-WebCrawler/2.2-pre27 (crawler\@fast.no; http://www.fast.no/faq/faqfastwebsearch/faqfastwebcrawler.html)
- Googlebot/2.1 (+http://www.googlebot.com/bot.html)
- Dual Proxy
- Opera/5.0 (Linux 2.2.16-22 i686; U) [en]
- In email and all other IO methods except the web server, the User-Agent will be "" (an empty string).
Examples
This example will show line 1 if the page was requested by MS Internet Explorer versions 5.5, line 2 if it was requested by the Opera browser, and line 3 for everybody else.
<!--#if condition="userAgent contains 'MSIE 5.5'"-->
1. You must be using MS Internet Explorer version 5.5.
<!--#if condition="userAgent beginsWith 'Opera'"-->
2. You're using the small-but-full-featured Opera browser to see this page.
<!--#else-->
3. Seeing this line means that you're not using MSIE 5.5 or Opera.
<!--#endIf-->
See the above code in action, here:
3. Seeing this line means that you're not using MSIE 5.5 or Opera
View in DG
|