javascript 将 IE8 用户重定向到另一个页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15471488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Redirect IE8 users to another page
提问by Catmandu
I am implementing a website with Wordpress, but my website is not supported in Internet Explorer 8.
我正在使用 Wordpress 实现一个网站,但 Internet Explorer 8 不支持我的网站。
Is there any code I can use so that any IE8 users will be redirected to another page?
有没有我可以使用的代码,以便将任何 IE8 用户重定向到另一个页面?
回答by Danny Beckett
I know you specified PHP, but here's a HTML/JS solution:
我知道你指定了 PHP,但这里有一个 HTML/JS 解决方案:
<!--[if IE]>
<script type="text/javascript">
window.location = "http://www.google.com/";
</script>
<![endif]-->
Taken from this answer.
取自这个答案。
If you specifically only want to redirect IE 8users, change <!--[if IE]>
to <!--[if IE 8]>
.
如果您只想重定向 IE 8用户,请更改<!--[if IE]>
为<!--[if IE 8]>
.
回答by Sudip Pal
Yes, in PHP you can use $_SERVER['HTTP_USER_AGENT']
to detect the browser and redirect accordingly.
In javascript you can you navigator.userAgent
to apply the same thing.
是的,在 PHP 中,您可以$_SERVER['HTTP_USER_AGENT']
用来检测浏览器并相应地重定向。在javascript中,你可以navigator.userAgent
应用同样的东西。