Html 重定向不是IE用户
在我的标题中,我有:Html 重定向不是IE用户,html,internet-explorer,Html,Internet Explorer,在我的标题中,我有: <!--[if lte IE 8]> <meta http-equiv="refresh" content="0; url=/ie-sucks" /> <script type="text/javascript"> /* <![CDATA[ */ window.top.location = '/ie-sucks'; /* ]]> */ </script> 但此代码不适用于Fiefox用户
<!--[if lte IE 8]>
<meta http-equiv="refresh" content="0; url=/ie-sucks" />
<script type="text/javascript">
/* <![CDATA[ */
window.top.location = '/ie-sucks';
/* ]]> */
</script>
但此代码不适用于Fiefox用户
我如何检测非IE用户并重定向他们
提前感谢你要做的就是把自己绑在绳结里,做你想做的事 如果用户使用的是IE8或更低版本,那么在页面顶部显示一条消息怎么样 您的信息只会建议升级他们的浏览器或下载Chrome、Firefox或任何东西,并且还可以关闭/隐藏信息
<!--[if lte IE 8]>
.my-message {
display: block;
}
<![endif]-->
正如我所说的,很愚蠢,但我的网站用户正在这样做,我正在通过谷歌分析追踪他们,其中两人看到了IE页面警报,然后打开Firefox并再次复制粘贴了准确的页面url,所以他们也看到了Firefox页面……呵呵,这是一种思考用户行为的好方法,我真的很佩服,但你真的不能“修正”所有可能的想法。可能是我,因为我有时也会这么做。查看源代码并尝试URL,看看其他程序员是如何解决/设计这一部分的。但是这两个用户占多少百分比呢?如果他们是50%,你真的应该关心。如果他们只有0005%,让他们试试看;)
<!--[if lte IE 8]>
.my-message {
display: block;
}
<![endif]-->
<?php
$useragent = $_SERVER['HTTP_USER_AGENT']; //get the user agent
if(!strpos($useragent, "MSIE")) {
// user agents from IE should always look like this and include 'MSIE':
// Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64)
header("Location: http://example.com/");
}
?>
if(navigator.userAgent.indexOf('MSIE') == -1) { ...