[英]Javascript redirect for Internet Explorer browser version user agent?
我发现我的javascript密集型网站在IE9中无法可靠(或根本没有)。
它通常(但不总是)使用标头中的兼容模式元标记,但我只想构建一个我知道在IE9中运行良好的页面,然后在检测到IE9时将常用页面重定向到它。 在IE 7和8(以及我尝试过的所有其他浏览器)中,通常的页面都很好。
任何人都可以给我一些javascript,这样做吗? 谢谢!
这是我常用的页面:
最简单的方法是使用IE Conditionals 。
注意: IE10及更高版本已取消对此功能的支持 。 对于现代浏览器,为了兼容性目的,有条件地显示内容的广泛接受的方式是使用特征检测 。 Modernizr是一个流行的库,用于处理特征检测。
例如:
<!--[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]-->
<script LANGUAGE="JavaScript">
<!--
if( navigator.appName.toLowerCase().indexOf("microsoft") > -1 ||
navigator.userAgent.toLowerCase().indexOf("msie") > -1 ) {
window.open("http://www.pobox.com/~qed/windoze.html", "Windoze",
"dependent=no,titlebar=no,scrollbars=yes" );
}
// Paul Hsieh
// qed at pobox dot com
// -->
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.