我已经创建了一个one web应用程序,它在火狐和chrome中运行良好,但在IE8中就不行了。
我尝试了在我的头中使用以下代码来设置文档模式:
<head>
<!-- meta tags -->
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="EmulateIE8" />
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
<meta name="author" content="Web">
<meta name="description" content="Medical Services">
<meta name="robots" content="index, follow">
<!-- mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="viewport" content="minimal-ui">
</head>我已经尝试过这段代码,但这不起作用。如果我使用开发人员工具在IE中手动选择文档模式"IE8标准“,那么它工作得很好。但我想将"IE8标准“设置为默认的文档模式。我该怎么做呢?请帮帮我。提前谢谢。
发布于 2014-05-30 20:50:54
当网站在您的本地主机上或本地网络上的另一台计算机上运行时,X-UA-Compatible标记将无法按预期工作。此外,标记在您的代码中出现两次,而它应该只列出一次。
删除其中一个标记,如果它仍然不能按预期工作,则需要在服务器上设置此标记。
如果您的网站运行ASP.NET,请在您的web.config中添加以下内容:
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE8" /> <!-- or other value of your choice -->
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>如果您的网站运行PHP,请将以下代码放在页面的第一行:
<?php
header('X-UA-Compatible: IE=EmulateIE8');
?>
<!-- or other value of your choice -->或者,如果您的站点在Apache中运行,请在.htaccess文件中将其设置为全局启用:
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1"
# Don't send it for non-HTML content
<FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>https://stackoverflow.com/questions/23954961
复制相似问题