Browser detection script

13. September 2010 15:07

This javascript will add a global browser object, with properties to match the current browser version.

Note: it does use navigator.userAgent strings for version detection. It should be used for resolving browser UI quirks, not in place of feature testing.

You can output the detection (after it is loaded) to say a div with an id of diagnostics via:

jQuery(function($){
    var bl = $('<dl></dl>');
    for (var x in browser) {
        if (!isNaN(browser[x] || undefined)) {
            bl.append(
                $('<dt></dt>').text(x)
            ).append(
                $('<dd></dd>').text(browser[x])
            );
        }
    };
    $('#diagnostics')    .append('<br /><br />')
                        .append(bl)
                        .append('<br class="clear" /><br />');
});
More...

Tracker1

Michael J. Ryan aka Tracker1

My name is Michael J. Ryan and I've been developing web based applications since the mid 90's.

I am an advanced Web UX developer with a near expert knowledge of JavaScript.