CssUserAgent Library

    In the vastness of the English-speaking Internet, I came across a javascript library with the speaking name CssUserAgent . In short, when loading the page, the classes of the following type are hung on the html tag : Under the description of the profit. As I said, when loading a page with this script, a number of classes are hung on the html tag , an example can be viewed by reference . For me personally, the result was as follows:
    ua-browsername
    ua-browsername-major
    ua-browsername-major-minor
    ua-browsername-major-minor-build
    ua-browsername-major-minor-build-revision




    
    
    …
    …
    
    

    For mobile browsers, a couple more classes will be added:

    What, besides the extra code, will we get?

    Firstly, the cssua.userAgent object is available to us , which in my case had the following form:
    cssua.userAgent = { webkit: "534.15", chrome: "10.0.612.3" };
    

    So now you can easily and simply define it as a version of IE:
    if (cssua.userAgent.ie < 8) { /* немного магии */ }
    

    both mobile browsers
    if (cssua.userAgent.mobile) { /* еще немного магии */ }
    


    And secondly, it’s a little easier to work with css code, which may depend on the browser:
    .logo-area
    {
    background-image: url(logo.png);
    background-repeat: no-repeat;
    background-position: left top;
    }
    /* для IE 5.0, 5.5, 6.0 */
    .ua-ie-5 .logo-area,
    .ua-ie-6 .logo-area
    {
    /* версии IE  < 7.0 плохо работают с 24-битными PNG */
    background-image: url(logo.gif);
    }
    


    I hope you find this library useful!

    Also popular now: