如何检测用户是否正在运行IE 6? [英] How to detect if a user is running IE 6?

查看:68
本文介绍了如何检测用户是否正在运行IE 6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够判断是否在IE 6中查看某个页面。如何在javascript中执行此操作而忽略7,8或其他浏览器等版本?

I need to be able to tell if a page is being viewed in IE 6. How can I do this in javascript while ignoring version like 7, 8, or other browsers?

推荐答案

直接来自马的嘴(和一个谷歌搜索):

straight from the horse's mouth (and one googling away):

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;
}

这篇关于如何检测用户是否正在运行IE 6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆