I was wondering, is it possible to supply a custom charset for a loaded iframe?
E.g if i have a page named www.example.com
with source code:
<meta charset=utf-7>
<html>
<body>
Test
</body>
</html>
Now i have a site named, www.example2.com
, what i want to do is load www.example.com
in an iframe
and set the charset of the loaded iframe
page to utf-8
, is this possible? if so how?
Thanks.
The page inside the iframe is completely independent of the "outer" page and it can have whatever charset you want. In other words, each page should specify its own charset (and make sure it's actually encoded in that charset).
By the way, your sample code is incorrect. The charset should be declared like this (assuming HTML 5):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-7">
</head>
<body>
Test
</body>
</html>
Alternatively, you can declare the charset via a HTTP header like this:
Content-Type: text/html; charset=utf-7
More details at http://www.w3.org/International/O-HTTP-charset
It's usually harder to configure the web server to output the correct header for each individual file which is why the meta
tag is more common.