0
|
1 /*
|
|
2 CSS Browser Selector v0.3.5 (Feb 05, 2010)
|
|
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 2. Set CSS attributes with the code of each browser/os you want to hack
|
|
8
|
|
9 Examples:
|
|
10
|
|
11 * html.gecko div#header { margin: 1em; }
|
|
12 * .opera #header { margin: 1.2em; }
|
|
13 * .ie .mylink { font-weight: bold; }
|
|
14 * .mac.ie .mylink { font-weight: bold; }
|
|
15 * .[os].[browser] .mylink { font-weight: bold; } -> without space between .[os] and .[browser]
|
|
16
|
|
17 Available OS Codes [os]:
|
|
18
|
|
19 * win - Microsoft Windows
|
|
20 * linux - Linux (x11 and linux)
|
|
21 * mac - Mac OS
|
|
22 * freebsd - FreeBSD
|
|
23 * ipod - iPod Touch
|
|
24 * iphone - iPhone
|
|
25 * webtv - WebTV
|
|
26 * mobile - J2ME Devices (ex: Opera mini)
|
|
27
|
|
28 Available Browser Codes [browser]:
|
|
29
|
|
30 * ie - Internet Explorer (All versions)
|
|
31 * ie8 - Internet Explorer 8.x
|
|
32 * ie7 - Internet Explorer 7.x
|
|
33 * ie6 - Internet Explorer 6.x
|
|
34 * ie5 - Internet Explorer 5.x
|
|
35 * gecko - Mozilla, Firefox (all versions), Camino
|
|
36 * ff2 - Firefox 2
|
|
37 * ff3 - Firefox 3
|
|
38 * ff3_5 - Firefox 3.5 new
|
|
39 * opera - Opera (All versions)
|
|
40 * opera8 - Opera 8.x
|
|
41 * opera9 - Opera 9.x
|
|
42 * opera10 - Opera 10.x
|
|
43 * konqueror - Konqueror
|
|
44 * webkit or safari - Safari, NetNewsWire, OmniWeb, Shiira, Google Chrome
|
|
45 * safari3 - Safari 3.x
|
|
46 * chrome - Google Chrome
|
|
47 * iron - SRWare Iron new
|
|
48
|
|
49 */
|
|
50 function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':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);
|