Differences

This shows you the differences between two versions of the page.

Link to this comparison view

expression function - user agent [2016/09/14 18:19]
expression function - user agent [2016/09/14 18:19] (current)
Line 1: Line 1:
 +====== User Agent (Expression Function) ======
  
 +===== Purpose =====
 +The **User Agent** function (USER_AGENT) returns the user agent string from the browser. ​ It is commonly used to present different content to end users based on the browser they are using. ​ This is sometimes necessary to work around bugs or feature limitations in certain browsers while providing the best possible experience to users using browsers without the bug or limitation. ​ This function could also be used to limit, modify, or remove functionality when a user is accessing an application from a mobile browser. Generally this feature should not be used to style the application differently for different browsers, as that should be handled using CSS via the [[CSS Skin Builder|CSS Style Builder]].
 +
 +{{ :​user_agent_initial.png?​nolink |}}
 +===== Parameters =====
 +The **User Agent** function has one optional parameter:
 +
 +==== Piece ====
 +
 +Allowed Inputs: browser, browser_version,​ mobile, tablet, os, os_version, comment
 +
 +To return the full user agent string as reported by the browser leave this parameter empty. ​ To pull a piece of the user agent string use one of the supported parameters. ​ Depending on what the browser reports any or all of the pieces may be missing. Possible return values for the pieces are:
 +
 +  * browser - Chrome, IE, Safari, Firefox, Opera, etc
 +  * browser_version - "​28.0",​ "​11.0",​ etc
 +  * mobile -  "​1"​ or ""​
 +  * tablet - "​1"​ or ""​
 +  * os - "​Win8.1","​Win7",​ "​WinVista",​ "​WinXP",​ "​Win2000",​ "​MacOSX",​ "​Linux",​ "​Android",​ "​iOS"​
 +  * os_version - unknown, "​10",​ "​6.1",​ etc
 +  * comment - "​Mobile Safari",​ "​Chrome 18.0", "IE 11.0", etc 
 +
 +===== Output =====
 +
 +The output of the **User Agent** function is a string.
 +
 +===== Example =====
 +
 +If the user agent reported by the browser was "​Mozilla/​5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/​IMM76B) AppleWebKit/​535.19 (KHTML, like Gecko) Chrome/​18.0.1025.133 Mobile Safari/​535.19",​ the output of: 
 +  * USER_AGENT() would return "​Mozilla/​5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/​IMM76B) AppleWebKit/​535.19 (KHTML, like Gecko) Chrome/​18.0.1025.133 Mobile Safari/​535.19"​
 +  * USER_AGENT("​browser"​) would return "​Chrome"​
 +  * USER_AGENT("​broser_version"​) would return "​18.0"​
 +  * USER_AGENT("​mobile"​) would be "​1"​
 +  * USER_AGENT("​tablet"​) would be ""​
 +  * USER_AGENT("​os"​) would be "​Android"​
 +  * USER_AGENT("​os_version"​) would be "​4.0"​
 +  * USER_AGENT("​comment"​) would be "​Chrome 18.0"
expression function - user agent.txt ยท Last modified: 2016/09/14 18:19 (external edit)
Copyright WorkXpress, 2024