开发者

iFrames and encodings

I am designing a web site that will rely on iFrames to show third party content. Given that, I have two problems.

  1. This third party content may come in different encodings.
  2. Almost nobody defines the encoding of a html file.

O开发者_如何学JAVAk, in this case the browser will try to infeer the encoding but as my tests shows it won´t infeer the encoding of each iframe sepparatly and, hence, some iframe will have it´s content messed up.

To reproduce create the following files:

index.html (encoded utf-8)

<html>
  <iframe src="utf.html"> </iframe>
  ááá
  <br />
  <iframe src="iso.html"> </iframe>
</html>

utf.html (encoded UTF-8)

<html>
  ááááéééé
</html>

iso.html (encoded ISO-8859-1)

<html>
  ááééíí
</html>

Right. If you see the results won´t be perfect.

If I add encoding info in meta tag properly it will work.

Remember I can´t change third party content. So, long story in short, the question is. In my example, is there a way to make it show all characters properly editing only index.html?

Thank you


There is not a way to do this client side. The browser will block this because of cross domain security policies. You will need to proxy the pages through your server and modify the output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜