From jQuery JavaScript Library
« Back to Utilities
jQuery.browser.version
The version number of the rendering engine for the user's browser.
Here are some typical results:
- Internet Explorer: 6.0, 7.0
- Mozilla/Firefox/Flock/Camino: 1.7.12, 1.8.1.3
- Opera: 9.20
- Safari/Webkit: 312.8, 418.9
Examples:| Name | Type |
Returns the browser version.
$("p").html("The browser version is: <span>" +
jQuery.browser.version + "</span>");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").html("The browser version is: <span>" +
jQuery.browser.version + "</span>");
});
</script>
<style>
p { color:blue; margin:20px; }
span { color:red; }
</style>
</head>
<body>
<p>
</p>
</body>
</html>
Alerts the version of IE that is being used
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:
if (jQuery.browser.msie) {
alert(parseInt(jQuery.browser.version));
}