你可以通过这样的navigator
对象来做到这一点:
var ua = navigator.userAgent;
if(navigator.appName == 'Microsoft Internet Explorer'){
//check for version
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null){
version = parseFloat( RegExp.$1 );
}
if(version == 6.0){
//load specific js for IE 6.0
var file = document.createElement("script");
file.setAttribute("type", "text/javascript");
file.setAttribute("src", "../js/ie_6.js");
document.getElementsByTagName("head")[0].appendChild(file);
}
else{
//load normal.js for other IE versions.
var file = document.createElement("script");
file.setAttribute("type", "text/javascript");
file.setAttribute("src", "../js/normal.js");
document.getElementsByTagName("head")[0].appendChild(file);
}
}