/msie 5\.[56789]/i
是一个REGEXP变量。

msie 5.5
msie 5.6
msie 5.7
msie 5.8
msie 5.9
对应。
这个是我写的函数。
是IE的就返回版本(字符串),否则就返回false
function GetIEVersion()
{
try
{
if(!window.clientInformation)return false;
if(window.clientInformation.appName.toLowerCase()!="microsoft internet explorer")return false;
if(window.clientInformation.appVersion.toLowerCase().indexOf("msie")==-1)return false;
var a=window.clientInformation.appVersion.toLowerCase().split(";");
for(var i=0;i<a.length;i++)
{
a[i]=a[i].replace(" ","");
if(a[i].indexOf("msie")==0)
{
var version=a[i].substr(4,a[i].indexOf(".")-2);
return version;
}
}
}
catch(exception)
{
}
return false;
}

解决方案 »

  1.   

    navigator.userAgent返回的值可能是:
    “Mozilla/4.0 (compatible; MSIE 5.0b; Windows 98)”
    其中:MSIE 5.0b是关键字,就可以用上面方法判断浏览器是不是IE5.x版的了。老外的内容有些过时了,现在都有IE 6.0了,还嫌版本不够高吗。
    如果要求IE5.0以上版本可以,可以自己编段代码试试。
      

  2.   

    是正则表达式,正则表达式是很复杂的,一时是说不清楚的,建议看一下MSDN。
    上述的
    /        /是把这个字符串括起来
    msie 就是 ie 的特征字符串。
    \.是"."
    [56789]是56789的任一个数字,也就说5.5,5.6,5.7,也就是大于5.5,IE5.5以后的版本。
    好边的.test我也不懂了
      

  3.   

    /msie 5\.[56789]/i是一个正则表达式,楼上的讲的已经比较清楚了,因为"."在正则式里有特殊含义(除 "\n" 之外的任何单个字符),所以这里"\."是一个原意字符,最后的/i表示忽略大小写;
      

  4.   

    .test是RegExp对象的一个方法,测试表达式在字符串里是否存在匹配,详细的情况可以看相关帮助
      

  5.   

    REGEXP 正则表达式对象原来如此,多谢各位了。
    老外还是比较牛的,他判断ie55是为了patch其中的一个bug,
    完整的代码如下:function hasSupport() { if (typeof hasSupport.support != "undefined")
    return hasSupport.support;

    var ie55 = /msie 5\.[56789]/i.test( navigator.userAgent );

    hasSupport.support = ( typeof document.implementation != "undefined" &&
    document.implementation.hasFeature( "html", "1.0" ) || ie55 )

    // IE55 has a serious DOM1 bug... Patch it!
    if ( ie55 ) {
    document._getElementsByTagName = document.getElementsByTagName;
    document.getElementsByTagName = function ( sTagName ) {
    if ( sTagName == "*" )
    return document.all;
    else
    return document._getElementsByTagName( sTagName );
    };
    } return hasSupport.support;
    }