1
function msieversion()
2
// Return Microsoft Internet Explorer (major) version number, or 0 for others.
3
// This function works by finding the "MSIE " string and extracting the version number
4
// following the space, up to the semicolon
5
{
6
var ua = window.navigator.userAgent
7
var msie = ua.indexOf ( "MSIE " )
8
if ( msie >= 0 ) // is Microsoft Internet Explorer; return version number
9
return parseFloat ( ua.substring ( msie+5, ua.indexOf ( ";", msie ) ) )
10
else
11
return 0 // is other browser
12
}

2

3

4

5

6

7

8

9

10

11

12

同样可以用这种方法判断是否为IE浏览器。
1
function isIE()
2
{
3
if(window.navigator.userAgent.indexOf("MSIE") >= 0)
4
return true;
5
else
6
return false;
7
}

2

3

4

5

6

7
