Skip to content

Instantly share code, notes, and snippets.

device = function(){
var flags = {}, ua = navigator.userAgent, el = document.createElement('div'), root = document.documentElement, i
function flag(names) {
root.className += (root.className ? ' ' : '') + names
names = names.split(' ')
for (i = 0; i < names.length; i++) flags[names[i]] = true
}
if (ua.indexOf('WebKit/') > -1) flag('webkit')
if (ua.indexOf('MSIE ') > -1) flag('msie')
if (ua.indexOf('Firefox') > -1) flag('firefox')