Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检测浏览器并显示其他内容_Javascript_Html_Css_Internet Explorer - Fatal编程技术网

Javascript 检测浏览器并显示其他内容

Javascript 检测浏览器并显示其他内容,javascript,html,css,internet-explorer,Javascript,Html,Css,Internet Explorer,我只使用CSS3和HTML5构建网站。 所以IE无法正确显示它。 我想向每一位Internet Explorer用户展示另一个具有简单内容的网站:请使用谷歌Chrome、Fire Fox等现代浏览器 如何检测浏览器并显示其他站点? 或者我可以为像这样的Internet Explorer用户创建文本吗 <div style="display:none;">Please use a modern Browser!</div> 请使用现代浏览器! 让我们只向Internet

我只使用CSS3和HTML5构建网站。 所以IE无法正确显示它。 我想向每一位Internet Explorer用户展示另一个具有简单内容的网站:请使用谷歌Chrome、Fire Fox等现代浏览器

如何检测浏览器并显示其他站点? 或者我可以为像这样的Internet Explorer用户创建文本吗

<div style="display:none;">Please use a modern Browser!</div>
请使用现代浏览器!

让我们只向Internet Explorer用户展示它吧?

您可以利用IE本身发出的IE检测。因此,将div与display none放在一起,然后制作一个ie样式表,并针对您想要的所有不同版本


更多细节信息请参见此处:

您可以利用IE检测IE自身发出的信号。因此,将div与display none放在一起,然后制作一个ie样式表,并针对您想要的所有不同版本


有关详细信息,请参见此处:

navigator.userAgent


这里有一个非常酷的脚本:

navigator.userAgent


这里有一个非常酷的脚本:

您可以使用以下脚本:

<?php
$u_agent = $_SERVER['HTTP_USER_AGENT']; 
if(preg_match('/MSIE/i', $u_agent)) 
{ 
    // Change http://www.othersite.com, by your other site URL
    header('Location: http://www.othersite.com'); 
} 
?>


您还可以对IE使用条件注释。

您可以使用以下内容:

<?php
$u_agent = $_SERVER['HTTP_USER_AGENT']; 
if(preg_match('/MSIE/i', $u_agent)) 
{ 
    // Change http://www.othersite.com, by your other site URL
    header('Location: http://www.othersite.com'); 
} 
?>


您还可以对IE使用条件注释。

有更好的选项,而不是添加新的样式表

<!doctype html>
<!--[if lt IE 7 ]> <html class="ie ie6" lang="en-US"> <![endif]-->
<!--[if IE 7 ]> <html class="ie ie7" lang="en-US"> <![endif]-->
<!--[if IE 8 ]> <html class="ie ie8" lang="en-US"> <![endif]-->
<!--[if IE 9 ]> <html class="ie ie9" lang="en-US"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en-US">
<!--<![endif]-->

这将使用单个样式表来完成

有更好的选择,而不是添加新的样式表

<!doctype html>
<!--[if lt IE 7 ]> <html class="ie ie6" lang="en-US"> <![endif]-->
<!--[if IE 7 ]> <html class="ie ie7" lang="en-US"> <![endif]-->
<!--[if IE 8 ]> <html class="ie ie8" lang="en-US"> <![endif]-->
<!--[if IE 9 ]> <html class="ie ie9" lang="en-US"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en-US">
<!--<![endif]-->

这将使用一个样式表来完成,IE支持CSS 3和HTML 5的合理子集。您是否搜索Interweb来检测IE?更好的方法是嗅探你所使用的东西的支持。看看大多数看到这样一条信息的人,他们要么不能,要么不愿意改变。内容为王。演示文稿可能会降级,但它应该降级。这不是让人们离开网站的原因。希望用户切换浏览器只是为了访问一个网站可能有点乐观。IE支持CSS 3和HTML 5的合理子集。你在互联网站上搜索过IE吗?更好的方法是嗅探你所使用的东西的支持。看看大多数看到这样一条信息的人,他们要么不能,要么不愿意改变。内容为王。演示文稿可能会降级,但它应该降级。这不是让人们离开网站的理由。希望用户只为了访问一个网站而切换浏览器可能有点乐观。标签在哪里?:)标签在哪里?:)很乐意帮忙!如果你不介意选择它作为你的正式答案(如果它对你来说是好的!),我将非常感激!很乐意帮忙!如果你不介意选择它作为你的正式答案(如果它对你来说是好的!),我将非常感激!
<!doctype html>
<!--[if lt IE 7 ]> <html class="ie ie6" lang="en-US"> <![endif]-->
<!--[if IE 7 ]> <html class="ie ie7" lang="en-US"> <![endif]-->
<!--[if IE 8 ]> <html class="ie ie8" lang="en-US"> <![endif]-->
<!--[if IE 9 ]> <html class="ie ie9" lang="en-US"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en-US">
<!--<![endif]-->