概述 jQuery.browser.version
返回值:String
描述:用户的浏览器渲染引擎的版本号。
以下是一些典型的结果:
请注意,IE8兼容性视要求成为ie 7。
示例
Returns the version number of the rendering engine used by the user's current browser. For example, FireFox 4 returns 2.0 (the version of the Gecko rendering engine it utilizes).
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- p { color:blue; margin:20px; }
- span { color:red; }
- </style>
- <script src="http://code.jquery.com/jquery-latest.js"></script>
- </head>
- <body>
-
- <p></p>
-
- <script>
- $("p").html( "The version number of the rendering engine your browser uses is: <span>" +
- $.browser.version + "</span>" );
- </script>
-
- </body>
- </html>
Alerts the version of IE's rendering engine that is being used:
- if ( $.browser.msie ) {
- alert( $.browser.version );
- }
Often you only care about the "major number," the whole number, which you can get by using JavaScript's built-in parseInt()
function:
- if ( $.browser.msie ) {
- alert( parseInt($.browser.version, 10) );
- }