Quick and Dirty

How do you solve the problem that a single page cannot display two sets of information in different character encodings under IE? I had this problem in the counterize plugin for WordPress, since the default page is in UTF-8 but the IP location information retrieved from somewhere else is in GB2312. So everytime I have to switch back and forth in IE -> View -> Encoding. Apparently Firefox does not have this problem. I don’t know how does it detects the GB2312 text and displays it correctly. But I do have a work around for this.

It is fairly simple. Create a separete page with its default encoding set to GB2312 and retrieves whatever information in GB2312 it wants. Then in the UTF-8 page that used to be problematic, replace the original script calls with iframe calls to the new GB2312 page. That’s it!

Example: Replace something like

<script src=”a.php?some=parameters”></script>

with something like

<iframe src=”b.php?some=parameters”></iframe>

where in b.php it passes some=parameters to a.php directly by using the script tag.

One more advantage is that when browser creates iframe objects, it creates a separate thread for loading the framed page. It allows constant information in the UTF-8 page to be displayed first while GB2312 page is loading, instead of waiting long for the GB2312 text to be retrieved and the displays the rest of the main page.

It is quick and dirty, but as long as it works, I’m fine with it. Remember to set the iframe to be borderless and transparent.


电子邮件地址不会被公开。 必填项已用*标注