【问题标题】:How to block access to a site from IE8 or less?如何阻止从 IE8 或更低版本访问网站?
【发布时间】:2014-01-20 11:26:34
【问题描述】:

我创建了一个基于 Extjs 4.2 的 javascript webapp。这个框架的很多特性不能在 IE8 上正常工作(我不知道以前版本的结果)。我正在寻找更干净的方法来阻止使用 IE8 或更少的用户代理访问我的网络应用程序以显示消息并避免登录到网络应用程序。

任何类型的帮助都是有用的

【问题讨论】:

  • 使用条件语句显示警告,告诉用户该网站无法在该浏览器上正常工作,不要完全阻止他们。

标签: javascript html internet-explorer user-agent extjs4.2


【解决方案1】:
if( ! Ext.isIE6 || ! Ext.isIE7 ) {
    yourapp.init();
} else {
    //show the element that directs people to http://browsehappy.com/
}

【讨论】:

  • 这可能是最简单、最有效的方法。感谢您的回答。
【解决方案2】:

我不会阻止访问,我会显示一条消息,指出此应用程序中的功能可能无法正常运行。拒绝访问是不好的。如果您想要简单的 IE8 检测结帐 ConditionizrIE8 detect(我创建了它):

/*!
 * IE8
 * @cc_on Conditional Compilation to test the
 * JavaScript versions
 */
conditionizr.add('ie8', [], function () {
  var version = false;
  /*@cc_on if (@_jscript_version > 5.7 && !/^(9|10)/.test(@_jscript_version))
  version = true @*/
  return version;
});

这给了你:

if (conditionizr.ie8) {
  // stuff for ie8
}

conditionizr.on('ie8', function () {
  // callbacks
});

此外,您还可以加载 polyfills/其他资源。也许您可以为非 IE8 加载 Ext.js,这样应用程序就不会中断,它只是不提供服务。

使用 Conditionizr,您也可以使用 ! 忽略浏览器:

conditionizr.on('!ie8'[, callback]);

【讨论】:

    【解决方案3】:

    只需在您的标记中使用IE's conditional statements 之一:

    <html>
        ...
        <body>
            <!--[if lte IE 8]>
                <p>Notice: As you are using an old browser some features of this
                   web app may not work for you. Please update.</p>
            <![endif]-->
            ...
        </body>
    </html>
    

    此处&lt;!--[if lte IE 8]&gt; 块中包含的任何内容都针对低于或等于 IE8 的任何 Internet Explorer 版本。

    【讨论】:

      猜你喜欢
      • 2011-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-27
      • 1970-01-01
      • 2014-07-18
      • 2012-09-16
      • 2021-02-01
      相关资源
      最近更新 更多