返回值:StringjQuery.browser.version
The version number of the rendering engine for the user's browser.
-
1.1.3 新增jQuery.browser.version
Here are some typical results:
- Internet Explorer: 6.0, 7.0
- Mozilla/Firefox/Flock/Camino: 1.7.12, 1.8.1.3, 1.9
- Opera: 9.20
- Safari/Webkit: 312.8, 418.9
Note that IE8 claims to be 7 in Compatibility View.
示例:
Returns the browser version.
<!DOCTYPE html>
<html>
<head>
<style>
p { color:blue; margin:20px; }
span { color:red; }
</style>
<script src="jquery.min.js"></script>
</head>
<body>
<p>
</p>
<script>
$("p").html("The browser version is: <span>" +
jQuery.browser.version + "</span>");
</script>
</body>
</html>
演示:
示例:
Alerts the version of IE that is being used
jQuery 代码:
if ( $.browser.msie ) {
alert( $.browser.version );
}
示例:
Often you only care about the "major number," the whole number. This can be accomplished with JavaScript's built-in parseInt() function:
jQuery 代码:
if (jQuery.browser.msie) {
alert(parseInt(jQuery.browser.version));
}