代码如下: /*written by xp in 8z at Mar 4,2010.QQ:251089096*/ var sUserAgent = navigator.userAgent; var isIE=isIE6=isIE7=isIE8=isFirefox=false; if(sUserAgent.indexOf("MSIE") > -1){ isIE = true; var version = sUserAgent.substr(sUserAgent.indexOf("MSIE")+5,3); if(version == "6.0"){isIE6=true;} if(version == "7.0"){isIE7=true;} if(version == "8.0"){isIE8=true;} } if(sUserAgent.indexOf("Firefox") > -1){isFirefox=true;}