如何判断网页是否在IE浏览器中打开?
- 内容介绍
- 文章标签
- 相关推荐
本文共计232个文字,预计阅读时间需要1分钟。
javascript检测浏览器类型和版本:var isIE=!!window.ActiveXObject;var isIE6=isIE && !window.XMLHttpRequest;var isIE8=isIE && !!document.documentMode;var isIE7=isIE && !isIE6 && !isIE8;if (isIE) { if (isIE6) { alert('ie6'); } else if (isIE8) { alert('ie8'); } else if (isIE7) { alert('ie7'); }}
//方式一 var isIE=!!window.ActiveXObject; var isIE6=isIE&&!window.XMLHttpRequest; var isIE8=isIE&&!!document.documentMode; var isIE7=isIE&&!isIE6&&!isIE8; if (isIE){ if (isIE6){ alert('ie6'); }else if (isIE8){ alert('ie8'); }else if (isIE7){ alert('ie7'); } }; //方式二 if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/6./i)=='6.'){ alert('IE 6'); } else if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/7./i)=='7.'){ alert('IE 7'); } else if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/8./i)=='8.'){ alert('IE 8'); } else if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/9./i)=='9.'){ alert('IE 9'); }; //方式三 if(navigator.userAgent.indexOf('Opera') != -1) { alert('Opera'); } else if(navigator.userAgent.indexOf('MSIE') != -1) { alert('Internet Explorer'); } else if(navigator.userAgent.indexOf('Firefox') != -1) { alert('Firefox'); } else if(navigator.userAgent.indexOf('Netscape') != -1) { alert('Netscape'); } else if(navigator.userAgent.indexOf('Safari') != -1) { alert('Safari'); } else{ alert('无法识别的浏览器。'); }; //方式四 if(!+'\v1' && !'1'[0]){ alert('ie6或ie7') }
本文共计232个文字,预计阅读时间需要1分钟。
javascript检测浏览器类型和版本:var isIE=!!window.ActiveXObject;var isIE6=isIE && !window.XMLHttpRequest;var isIE8=isIE && !!document.documentMode;var isIE7=isIE && !isIE6 && !isIE8;if (isIE) { if (isIE6) { alert('ie6'); } else if (isIE8) { alert('ie8'); } else if (isIE7) { alert('ie7'); }}
//方式一 var isIE=!!window.ActiveXObject; var isIE6=isIE&&!window.XMLHttpRequest; var isIE8=isIE&&!!document.documentMode; var isIE7=isIE&&!isIE6&&!isIE8; if (isIE){ if (isIE6){ alert('ie6'); }else if (isIE8){ alert('ie8'); }else if (isIE7){ alert('ie7'); } }; //方式二 if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/6./i)=='6.'){ alert('IE 6'); } else if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/7./i)=='7.'){ alert('IE 7'); } else if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/8./i)=='8.'){ alert('IE 8'); } else if(navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.match(/9./i)=='9.'){ alert('IE 9'); }; //方式三 if(navigator.userAgent.indexOf('Opera') != -1) { alert('Opera'); } else if(navigator.userAgent.indexOf('MSIE') != -1) { alert('Internet Explorer'); } else if(navigator.userAgent.indexOf('Firefox') != -1) { alert('Firefox'); } else if(navigator.userAgent.indexOf('Netscape') != -1) { alert('Netscape'); } else if(navigator.userAgent.indexOf('Safari') != -1) { alert('Safari'); } else{ alert('无法识别的浏览器。'); }; //方式四 if(!+'\v1' && !'1'[0]){ alert('ie6或ie7') }

