Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css_browser_selector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css_browser_selector_dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function css_browser_selector(u)
b= [

// browser
(!(/opera|webtv/i.test(ua))&&/msie\s(\d+)/.test(ua))?('ie ie'+(/trident\/4\.0/.test(ua) ? '8' : RegExp.$1))
(!(/opera|webtv|firefox/i.test(ua))&&/trident|msie/i.test(ua)&&/(msie\s|rv\:)(\d+)/.test(ua))?('ie ie'+(/trident\/4\.0/.test(ua) ? '8' : RegExp.$2))
:is('firefox/')?g+ " " + f+(/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+f+RegExp.$2 + ' '+f+RegExp.$2+"_"+RegExp.$4:'')
:is('gecko/')?g
:is('opera')?o+(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+o+RegExp.$2 + ' '+o+RegExp.$2+"_"+RegExp.$4 : (/opera(\s|\/)(\d+)\.(\d+)/.test(ua)?' '+o+RegExp.$2+" "+o+RegExp.$2+"_"+RegExp.$3:''))
Expand Down
71 changes: 71 additions & 0 deletions tests/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<head>
<title>CSS Browser Selector - Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<style type="text/css">
.ie .example {
background-color: yellow
}
.ie7 .example {
background-color: orange
}
.gecko .example {
background-color: gray
}
.win.gecko .example {
background-color: red
}
.linux.gecko .example {
background-color: pink
}
.opera .example {
background-color: green
}
.konqueror .example {
background-color: blue
}
.webkit .example {
background-color: black
}
.example {
width: 100px;
height: 100px;
}
.no_js { display: block }
.has_js { display: none }
.js .no_js { display: none }
.js .has_js { display: block }
</style>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="../css_browser_selector.js"></script>
</head>
<body>
<h1>CSS Browser Selector - Example</h1>
<div class="no_js" style="color: red; font-weight: bold">
<p>The JavaScript support is disabled on your browser. Please, enable JavaScript and refresh this page.</p>
</div>
<div class="has_js">
<div class="example"></div>

<p>The color of this box will change on different os/browsers:</p>
<ul>
<li>Internet Explorer - yellow</li>
<li>Internet Explorer 7 - orange</li>
<li>Gecko Engine on Windows (Firefox, Mozilla, Camino) - red</li>
<li>Gecko Engine on Linux (Firefox, Mozilla, Camino) - pink</li>
<li>Gecko Engine on Other OS (Firefox, Mozilla, Camino) - gray</li>
<li>Opera - green</li>
<li>Konqueror - blue</li>
<li>Safari - black</li>
<li>Chrome - cyan</li>
</ul>
<h2>Current browser UserAgent string:</h2>
<div id="useragent"></div>
<script type="text/javascript">
document.getElementById('useragent').innerHTML = navigator.userAgent.toLowerCase();
</script>
</div>
</body>
</html>
6 changes: 6 additions & 0 deletions tests/tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
["Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) Opera 6.01 [en]" , "opera opera6 win"], // Opera 6.01 on Windows 95.
["Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 5.0 [en]" , "opera opera5 mac"], // Opera 5.0 on the Mac (OS8.6)
// Internet Explorer
["Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" , "ie ie11 win"],
["Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko" , "ie ie11 win"],
["Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko" , "ie ie11 win"],
["mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; infopath.3; .net4.0c; .net4.0e; rv:11.0) like gecko" , "ie ie11 win"],
["Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" , "ie ie10 win"],
["Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" , "ie ie9 win"],
["mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1) ; .net clr 1.1.4322; .net clr 2.0.50727; .net clr 3.0.4506.2152; .net clr 3.5.30729; officeliveconnector.1.4; officelivepatch.1.3)", "ie ie8 win"],
["Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)" , "ie ie8 win"],
["Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)" , "ie ie8 win"],
Expand Down