用于Internet Explorer浏览器版本用户代理的Javascript重定向? [英] Javascript redirect for Internet Explorer browser version user agent?

查看:176
本文介绍了用于Internet Explorer浏览器版本用户代理的Javascript重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现我的javascript密集型网站在IE9中无法可靠(或根本没有)。

I found out that my javascript-intensive web site doesn't work reliably (or at all) in IE9.

它在标题中使用兼容模式元标记(通常但不总是),但我只是想构建一个我知道可以很好地工作的页面IE9然后在检测到IE9时将常用页面重定向到它。在IE 7和8(以及我尝试过的所有其他浏览器)中,通常的页面都很好。

It works, (usually, but not always) with the compatibility mode meta tag in the header, but I just want to build a page that I know will work well in IE9 and then have the usual page redirect to it when IE9 is detected. The usual page is fine in IE 7 and 8 (and every other browser I've tried it on).

任何人都可以给我一些javascript来做到这一点吗?谢谢!

Can anyone give me some javascript that will do that? Thank you!

这是我的常用页面:

http://ianmartinphotography.com/test-site/test/

推荐答案

最简单的方法是使用 IE条件

The simplest way would be to use IE Conditionals.

注意: IE10及更高版本删除了此功能的支持。对于现代浏览器,为了兼容性目的,有条件地显示内容的广泛接受的方法是使用特征检测 Modernizr 是一个用于处理特征检测的流行库。

Note: IE10 and beyond have removed support for this feature. For modern browsers the widely accepted way of conditionally displaying content for compatibility purposes is using feature detection. Modernizr is a popular library built for handling feature detection.

例如:

<!--[if IE 9]>
<script type="text/javascript">
    window.location = "http://www.ie9version.com";
</script>
<![endif]-->

条件网站的例子:

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

<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->

<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->

<!--[if true]>You are using an <em>uplevel</em> browser.<![endif]-->
<![if false]>You are using a <em>downlevel</em> browser.<![endif]>

<!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->

这篇关于用于Internet Explorer浏览器版本用户代理的Javascript重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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