<html>
<body>
<script type="text/javascript">
var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)
document.write("浏览器名称:"+ browser)
document.write("<br />")
document.write("浏览器版本:"+ version)
</script>
</body>
</html>

http://wenku.baidu.com/link?url=II5JksR2PojfPzBF14vNmQeqPkmveFjqQqYroiZHTuMii2bXRDGoitTKDZCSNtoq-_5ZgwqumYVgvOb0U9hwJD9nJQ64g7ToLN0hYyfz8Ja

[Web开发] 检测IE版本号的方法总结

检测浏览器(比如IE)的版本号码是Web 开发最常遇到的问题之一, 以下总结几种检测IE版本号码的方法:

通过Javascript解释浏览器的 User-Agent 字符串:

Javascript代码 1.function getInternetExplorerVersion()   2.// Returns the version of Internet Explorer or a -1   3.// (indicating the use of another browser).   4.{   5.  var rv = -1; // Return value assumes failure.   6.  if (navigator.appName == 'Microsoft Internet Explorer')   7.  {   8.    var ua = navigator.userAgent;   9.    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");   10.    if (re.exec(ua) != null)   11.      rv = parseFloat( RegExp.$1 );   12.  }   13.  return rv;   14.}   15.function checkVersion()   16.{   17.  var msg = "You're not using Internet Explorer.";   18.  var ver = getInternetExplorerVersion();   19.  20.  if ( ver > -1 )   21.  {   22.    if ( ver >= 8.0 )    23.      msg = "You're using a recent copy of Internet Explorer."  24.    else  25.      msg = "You should upgrade your copy of Internet Explorer.";   26.  }   27.  alert( msg );   28.}  function getInternetExplorerVersion() // Returns the version of Internet Explorer or a -1 // (indicating the use of another browser). {   var rv = -1; // Return value assumes failure.   if (navigator.appName == 'Microsoft Internet Explorer')   {     var ua = navigator.userAgent;     var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");     if (re.exec(ua) != null)       rv = parseFloat( RegExp.$1 );   }   return rv; } function checkVersion() {   var msg = "You're not using Internet Explorer.";   var ver = getInternetExplorerVersion();

if ( ver > -1 )   {     if ( ver >= 8.0 )       msg = "You're using a recent copy of Internet Explorer."     else       msg = "You should upgrade your copy of Internet Explorer.";   }   alert( msg ); }

通过Javascript判断IE渲染引擎的的当前渲染模式:

Javascript代码 1.engine = null;   2.if (window.navigator.appName == "Microsoft Internet Explorer")   3.{   4.   // This is an IE browser. What mode is the engine in?   5.   if (document.documentMode) // IE8   6.      engine = document.documentMode;   7.   else // IE 5-7   8.   {   9.      engine = 5; // Assume quirks mode unless proven otherwise   10.      if (document.compatMode)   11.      {   12.         if (document.compatMode == "CSS1Compat")   13.            engine = 7; // standards mode   14.      }   15.   }   16.   // the engine variable now contains the document compatibility mode.   17.}  engine = null; if (window.navigator.appName == "Microsoft Internet Explorer") {    // This is an IE browser. What mode is the engine in?    if (document.documentMode) // IE8       engine = document.documentMode;    else // IE 5-7    {       engine = 5; // Assume quirks mode unless proven otherwise       if (document.compatMode)       {          if (document.compatMode == "CSS1Compat")             engine = 7; // standards mode       }    }    // the engine variable now contains the document compatibility mode. }

通过ASP.NET 的 HttpBrowserCapabilities 对象:

C-sharp代码 1.private float getInternetExplorerVersion()   2.{   3.  // Returns the version of Internet Explorer or a -1   4.  // (indicating the use of another browser).   5.  float rv = -1;   6.  System.Web.HttpBrowserCapabilities browser = Request.Browser;   7.  if (browser.Browser == "IE")   8.    rv = (float)(browser.MajorVersion + browser.MinorVersion);   9.  return rv;   10.}   11.  12.private void Page_Load(object sender, System.EventArgs e)   13.{   14.  string msg;   15.  double ver = getInternetExplorerVersion();   16.  if (ver > 0.0)   17.  {   18.    if (ver >= 7.0)    19.      msg = "You're using a recent version of Internet Explorer.";   20.    else  21.      msg = "You should upgrade your copy of Internet Explorer.";   22.  }    23.  else  24.    msg = "You're not using Internet Explorer.";   25.  26.  Label1.Text = msg;   27.}  private float getInternetExplorerVersion() {   // Returns the version of Internet Explorer or a -1   // (indicating the use of another browser).   float rv = -1;   System.Web.HttpBrowserCapabilities browser = Request.Browser;   if (browser.Browser == "IE")     rv = (float)(browser.MajorVersion + browser.MinorVersion);   return rv; }

private void Page_Load(object sender, System.EventArgs e) {   string msg;   double ver = getInternetExplorerVersion();   if (ver > 0.0)   {     if (ver >= 7.0)       msg = "You're using a recent version of Internet Explorer.";     else       msg = "You should upgrade your copy of Internet Explorer.";   }   else     msg = "You're not using Internet Explorer.";

Label1.Text = msg; }

通过HTML的扩展注释语句:

Xhtml代码 1.<!--[if gte IE 8]>  2.<p>You're using a recent version of Internet Explorer.</p>  3.<![endif]-->  4.  5.<!--[if lt IE 7]>  6.<p>Hm. You should upgrade your copy of Internet Explorer.</p>  7.<![endif]-->  8.  9.<![if !IE]>  10.<p>You're not using Internet Explorer.</p>  11.<![endif]>  <!--[if gte IE 8]> <p>You're using a recent version of Internet Explorer.</p> <![endif]-->

<!--[if lt IE 7]> <p>Hm. You should upgrade your copy of Internet Explorer.</p> <![endif]-->

<![if !IE]> <p>You're not using Internet Explorer.</p> <![endif]>

有些方法在之前的blog文章提过

http://blog.csdn.net/WinGeek/archive/2009/02/08/3868150.aspx

http://blog.csdn.net/WinGeek/archive/2009/01/31/3855405.aspx

MSDN参考文章:(1), (2)

IE版本检测的更多相关文章

  1. ios应用启动后的自动版本检测方式

    今天意外的发现了appstore居然还提供通过url获取json格式的客户端信息链接: http://itunes.apple.com/lookup?id=$id 通过此地址可以获取应用的icon.介 ...

  2. SWFObject: 基于Javascript的Flash媒体版本检测与嵌入模块

    原文地址:http://www.awflasher.com/flash/articles/swfobj.htm SWFObject: 基于Javascript的Flash媒体版本检测与嵌入模块原文:S ...

  3. 苹果拒绝App内部使用版本检测功能

    10.6 - Apple and our customers place a high value on simple, refined, creative, well thought through ...

  4. PPK提供的浏览器类型及版本检测方法

    PPK提供的浏览器类型及版本检测方法   一个常用但是被高估的Javascript函数就是浏览器检测.有些时候,你想给出一个说明或者加载一个页面来提示用户,以免使用Safari等浏览器. 使用方法: ...

  5. _1Python简介 安装及版本检测

    简介 Python是一种面向对象的解释性计算机程序设计语言,由荷兰人Guido von Rossum于1988年的圣诞节发明,第一个公开发行版于1991年. Python崇尚优美.清晰.简单,是一个优 ...

  6. Android服务器——使用TomCat实现软件的版本检测,升级,以及下载更新进度!

    Android服务器--使用TomCat实现软件的版本检测,升级,以及下载更新进度! 算下来,TomCat服务器已经写了很长一段时间了,一直说拿他来搞点事 情,也一直没做,今天刚好有空,交流群还有人请 ...

  7. Nmap版本检测

    -sV (版本检测) 打开版本检测.同时可以使用-A打开系统探测和版本探测. --allports(不为版本探测排除任何端口) 默认情况下,Nmap版本探测会跳过9100 TCP端口,也可以不理会任何 ...

  8. winform软件版本检测自动升级开发流程(转)

    注:按此博文试验OK 基于C/S的开发有开发效率高,对于业务逻辑复杂,且不需要外网使用具有较大优势,但是弊端也不可忽视,就是升级麻烦,不可能每写一个版本就要拿着安装包给每个人去替换,这样不仅搞得自己很 ...

  9. Dependabot 开始支持 pub package 版本检测

    今年年初,我们发布了 Flutter 2022 产品路线图,其中「基础设施建设」这部分提到:2022 年 Flutter 团队将增加对供应链的安全的投入,目的是达到符合基础设施 SLSA 4 级别中描 ...

  10. javascript之IE版本检测

    近年来随着操作系统的升级以及各种新技术的开发普及,抛弃低版本IE已经是大势所趋,这对于前端人员来时是个好消息,可以不用花费太多的时间来做低版本的兼容,很多站点采用给予低版本IE以提示的方式(恩,很友好 ...

随机推荐

  1. js 正则去除指定的单词

    以企业邮箱为例:@后面不能是qq   126   163  188 gmail   yahoo   sina   hotmail  suhu   sogu  等单词. <!DOCTYPE htm ...

  2. 封装一个简单的原生js焦点轮播图插件

    轮播图实现的效果为,鼠标移入左右箭头会出现,可以点击切换图片,下面的小圆点会跟随,可以循环播放(为了方便理解,没有补2张图做无缝轮播).本篇文章的主要目的是分享封装插件的思路. 轮播图我一开始是写成非 ...

  3. PHP与MYSQL数据库链接方法

    <?php //Mysqli链接数据库的方法 $host='localhost';//主机地址 $dbname='mydata2017';//数据库名 $username='root';//用户 ...

  4. webservice 基本要点

    webservice的特点 webservices是自我包含的 webservices是自我描述的 webservices是跨平台和语言的 webservices是基于开放和标准的 webservic ...

  5. 什么是 SSO 与 CAS?

    SSO SSO 是英文 Single Sign On 的缩写,翻译过来就是单点登录.顾名思义,它把两个及以上个产品中的用户登录逻辑抽离出来,达到只输入一次用户名密码,就能同时登录多个产品的效果. 打个 ...

  6. Maven中使用Jetty容器

    1.在pom.xml中添加Jetty的插件 <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId ...

  7. L1-037 A除以B

    真的是简单题哈 —— 给定两个绝对值不超过100的整数A和B,要求你按照“A/B=商”的格式输出结果. 输入格式: 输入在第一行给出两个整数A和B(−100≤A,B≤100),数字间以空格分隔. 输出 ...

  8. DevExpress v17.2新版亮点—DevExtreme篇(三)

    用户界面套包DevExpress DevExtreme v17.2终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExtreme v17.2 的New Color Sche ...

  9. linux 简单常用命令

    kill -3 pid就是发送信号3也就是SIGQUIT给进程pid.kill -9 就是发信号9也就是SIGKILL. pwd: 打印当前工作目录ls:默认显示当前工作目录内容cd:改变当前工作目录 ...

  10. Linux C 中获取local日期和时间 time()&localtime()函数

    1.  time() 函数 /* time - 获取计算机系统当前的日历时间(Calender Time) * 处理日期时间的函数都是以本函数的返回值为基础进行运算 * * 函数原型: * #incl ...