iFrame 中的 CSS:它显示 CSS 代码,而不是加载和应用它
我的 PHP 页面上有一个 iFrame,在某些情况下,在某些机器上的某些浏览器中,它不是正常加载 CSS 并将样式应用于 iFrame 内容,而是以纯文本模式显示 CSS 代码。
有谁知道为什么这可能?
正常的方式应该是,PHP 页面加载 iframe,最后一个正常加载内容,并且此 iFrame 中的所有内容都显示出精美的样式。但正如我所说,在特定用户(只有他)的机器上的 Chrome 中,它不会以这种方式工作。相反,当 PHP 页面加载完成时,我们会在 iframe 中看到 CSS 代码。
I have an iFrame on a PHP page that in some cases and in just some browsers in some machines, instead of loading the CSS normally and aplying the style over the iFrame contents, it just shows the CSS code in a plain text mode.
Does anyone know why this could be possible?
Normal way should be, PHP page loading the iframe, this last one loading the content normally and everything appearing beautifully styled inside this iFrame. But as I said, in Chrome in a machine from a specific user (and just him) it doesn't work this way. Instead of this, we see the CSS code inside the iframe when PHP page finishes loading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 iframe 的 http 请求上发送的标头,特别是“Content-Type”标头。在某些情况下,以
text/plain
形式提供的文档将无法正确呈现为 HTML 和 CSS。相反,您只会看到原始代码。如果您的 Web 服务器未将文件解析为 PHP,而只是解析纯文本文件,也可能会发生这种情况。例如,尝试将
.php
脚本重命名为.myphp
,然后在浏览器中访问该 URL。您可能会看到 PHP 源代码,甚至可能会看到未处理的 HTML 和 CSS。Check the headers that are being sent on the iframe's http request, specifically the "Content-Type" header. In some cases, a document that is served as
text/plain
will not render properly as HTML and CSS. Instead, you will just see the raw code.This can also happen if your web server is not parsing the file as PHP, but just a plain text file. For example, try renaming a
.php
script to.myphp
and then visit the URL in your browser. You will probably see the PHP source code and maybe even unprocessed HTML and CSS.