在iframe中字符编码 [英] Character Encoding in iframes

查看:980
本文介绍了在iframe中字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件中EN ISO-8859-1 codeD。如果您在谷歌Chrome浏览器查看它,它显示正确。但是,如果您的iframe它,它看起来是错误的。此外,它看起来总是错在Firefox浏览器。

I have a text file encoded in ISO-8859-1. If you view it in Google Chrome, it displays correctly. However, if you iframe it, it looks wrong. Also, it always looks wrong in Firefox.

我注意到各种不同的服务器和浏览器同样的行为。不过,如果我使用谷歌Chrome和运行在同一台机器上的服务器和浏览器的iframe的内容显示正确。

I have noticed this same behavior with various different servers and browsers. However, if I use Google Chrome and run the server and browser on the same machine, the iframe's content displays correctly.

我应该怎么做,以使文件在所有情况下正常显示?这似乎是浏览器应该能够弄清楚,但在许多情况下,它没有这样做。

What should I do to make the file show up correctly in all situations? It seems like the browser should be able to figure it out, but in many situations it fails to do so.

推荐答案

您正在使用服务文件的Content-Type:text / plain的,这相当于要求浏览器的猜测。显然,不是每一个情况导致在相同的猜测。

You’re serving the file with Content-Type: text/plain, which amounts to asking the browser to guess. Evidently, not every situation results in the same guess.

设置为的Content-Type:text / plain的;字符集= ISO-8859-1

这篇关于在iframe中字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆