How do you detect between a Desktop and Mobile Chrome User Agent?

The problem is the user agent will always have “Chrome” whether it is the desktop or mobile version. So you have to check the more specific case first.

$(document).ready(function(){
    var ua = navigator.userAgent;

    if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua))
       $('a.mobile-other').show();

    else if(/Chrome/i.test(ua))
       $('a.chrome').show();

    else
       $('a.desktop-other').show();
});

Leave a Comment