header("Content-type: text/css");
适用于 Firefox、Chrome 等,但不适用于 Internet Explorer 9.我不确定发生了什么.
header("Content-type: text/css");
works in Firefox, Chrome and other, but not in Internet Explorer 9. I am not sure what's up.
在 Chrome 和 Firework 中,如果我在自己的选项卡中打开样式表并将其应用于页面,它会显示样式表.
In Chrome and Firework it shows the style sheet if I open it in its own tab and it's being applied to the page.
在开发者工具中网络下的 Chrome 中,它显示类型为 text/css
,状态为 200.
In Chrome under Network in the developer tools it says the type is text/css
and the status is 200.
在 Internet Explorer 9 中,如果我在自己的选项卡中打开样式表并且它没有被应用到页面,它想要下载样式表.
In Internet Explorer 9, it wants to download the style sheet if I open it in its own tab and it's not being applied to the page.
在 F12 开发者工具中,您可以点击网络,开始捕获并刷新页面.它显示了 Style.css.php
.类型为text/html
,结果为406.
In the F12 developer tools you can click on network, start capturing and refresh the page. It shows the Style.css.php
. The type is text/html
and the result is 406.
这是在头脑中:
<link rel="stylesheet" type="text/css" href="/assets/css/style.css.php" media="screen" />
请求标头:
Key Value
Request GET /assets/css/main.css HTTP/1.1
Accept text/css
Referer http://10.0.1.5/
Accept-Language en-US
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding gzip, deflate
Host 10.0.1.5
Connection Keep-Alive
Cookie PHPSESSID=*Hidden*
响应标头:
Key Value
Response HTTP/1.1 406 Not Acceptable
Date Fri, 01 Apr 2011 10:12:42 GMT
Server Apache/2.2.14 (Ubuntu)
Alternates {"main.css.php" 1 {type application/x-httpd-php}}
Vary negotiate
TCN list
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Content-Type text/html; charset=iso-8859-1
IE有不,我不是在开玩笑 Content-Type" 开关:
X-Content-Type-Options: nosniff
顺便说一句:确保您还发送 Last-Modified
并在 PHP 中禁用 session.cache_limiter
,否则浏览器将不断重新加载 CSS 文件,这将对性能产生负面影响.
BTW: make sure you also send Last-Modified
and disable session.cache_limiter
in PHP, otherwise browsers will keep reloading the CSS file, which will negatively impact performance.
这篇关于header(“内容类型:文本/css");在 Firefox 和 Chrome 中运行,但在 Internet Explorer 9 中显示为“text/html"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!