header(“内容类型:文本/css");在 Firefox 和 Chrome 中运行,但在 Interne

2024-08-22php开发问题
6

本文介绍了header(“内容类型:文本/css");在 Firefox 和 Chrome 中运行,但在 Internet Explorer 9 中显示为“text/html"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17