Posted By

rtcrm on 10/28/08


Tagged

css js selector rtcrm broswer


Versions (?)

Who likes this?

11 people have marked this snippet as a favorite

ahjo
jamesming
SpinZ
joaosalless
wizard04
rwczippy
jeremyhcobb
umang_nine
seanpowell
guo3823538
bcmoney


CSS Browser Selector


 / Published in: JavaScript
 

URL: http://rafael.adm.br/css_browser_selector

CSS Browser Selector is a very small javascript with just one line and less than 1kb which empower CSS selectors. It gives you the ability to write specific CSS code for each operating system and each browser.

Available OS Codes [os]:

win - Microsoft Windows

linux - Linux (x11 and linux)

mac - Mac OS

freebsd - FreeBSD

ipod - iPod Touch

iphone - iPhone

webtv - WebTV

mobile - J2ME Devices (ex: Opera mini)

Available Browser Codes [browser]:

ie - Internet Explorer (All versions)

ie8 - Internet Explorer 8.x

ie7 - Internet Explorer 7.x

ie6 - Internet Explorer 6.x

ie5 - Internet Explorer 5.x

gecko - Mozilla, Firefox (all versions), Camino

ff2 - Firefox 2

ff3 - Firefox 3

opera - Opera (All versions)

opera8 - Opera 8.x

opera9 - Opera 9.x

opera10 - Opera 10.x

konqueror - Konqueror

webkit - Safari, NetNewsWire, OmniWeb, Shiira, Google Chrome

safari - Safari, NetNewsWire, OmniWeb, Shiira

safari3 - Safari 3.x

chrome - Google Chrome

Extra Codes:

js - Will be available when js is enable, so you can show/hide some stuffs

RTCRM

  1. /*
  2. CSS Browser Selector v0.3.2
  3. Rafael Lima (http://rafael.adm.br)
  4. http://rafael.adm.br/css_browser_selector
  5. License: http://creativecommons.org/licenses/by/2.5/
  6. Contributors: http://rafael.adm.br/css_browser_selector#contributors
  7. */
  8. function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

Report this snippet  

You need to login to post a comment.