<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. Error when clicking other button after displaying Popup window(转)

    原文地址:Error when clicking other button after displaying Popup window Hi, I'm developing a custom page ...

  2. 使用 istreambuf_iterator 读取文件内容,赋值给 std::string

    需要一个一个字符输入时考虑使用istreambuf_iterator 假设我们要把一个文本文件拷贝到一个字符串对象中.似乎可以用一种很有道理的方法完成: ifstream inputFile(&quo ...

  3. laravel日志:

    laravel日志写入方法之一: Log::info('Showing user profile for user: 147258369');把日志写入到某个方法中之后,执行方法之后,日志存储起来. ...

  4. Awk 从入门到放弃 (6) Awk模式(Pattern)之二

    第一题:从/etc/passwd 匹配以 vmuser开头的用户 grep “^vmuser”   /etc/passwd  -r  -n awk  ‘/^vmuser /{print $0}’  / ...

  5. (C#基础)创建文件,文件夹

    文件夹,文件这是常见的,怎么创建?要不要先判断是否存在?非常非常基础的知识点. 代码 using System; using System.Collections.Generic; using Sys ...

  6. POJ 2057 The Lost Home 树形dp 难度:2

    The Lost House Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 2203   Accepted: 906 Des ...

  7. scrapy-redis(七):部署scrapy

    一般我们写好scrapy爬虫,如果需要启动的话,需要进入scrapy项目的根目录,然后运行以下命令: scrapy crawl {spidername} 这样我们就可以在终端查看到爬虫信息了.但爬虫运 ...

  8. 51nod1482

    题解: 发现是一个环,而环的题目有一些就是要转化成为链 首先找到一个最高点,中间断开 然后当作一条链来做 代码: #include<cstdio> #include<algorith ...

  9. C++内置类型的机器实现

    大多数计算机以2的整数次幂个比特作为块来处理内存,可寻址的最小内存块称为“字节(byte)”,存储的基本单元称为“字(word)”,它通常有几个字节组成. 计算机以比特序列存储数据,即01000101 ...

  10. python __new__ __init__

    写过python类的都会知道__init__,可能也了解__new__.我之前也了解__new__,但只做的它发生在__init__之前.其他的就比较模糊了 今天在学习单例模式时,看到有人用__new ...