To detect the User Agent in YUI, you have to examine the YAHOO.env.ua hash.
The hash is populated by key-value pairs of the engine name and the engine version.
For example, YAHOO.env.ua.gecko might contain a value of 1.7 or 1.8. If the engine is not present at all (i.e: you’re using MSIE), it evaluates to zero. This means that you can simply check like this if you want to detect any version of Gecko (Firefox):
if(YAHOO.env.ua.gecko)) do_something()
or like this if you need to target specific versions:
if(YAHOO.env.ua.gecko > 1.7) do_something()
The engine names are gecko, ie, opera, webkit, air and mobile. More information check the API
To have YAHOO.env make sure you’re including yahoo.js in your page