471,852 Members | 1,077 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

Character encoding after window.open()


I have a small javascript snippet that does the following:

Expand|Select|Wrap|Line Numbers
  1. // an entire html document is in here
  2. data = "\u003c!DOCTYPE html PUBLIC \u0022-//W3C//DTD XHTML 1.1 Strict//EN\u0022\n  ...."; 
  4. newwin = window.open("", "outputwin", "");
  5. newwin.document.write(data);
  6. newwin.document.close();
Now, in the data variable, the character encoding is set to be UTF-8 using a meta http-equiv tag. Same for the page that contains this script.

When I look at the character encoding in the Firefox ( "View Page Info" dialogue box, it tells me the following:

The original page has an Encoding of UTF-8 and the Content-type is text/html; charset=utf-8

The new page, however, has an Encoding of ISO-8859-1 but the Content-type is shown as text/html; charset=utf-8.

This is the case when there are non-ISO-8895-1 characters present although they are correctly displayed.


* Is this something to be worried about?

* Is this something I can address in the javascript? (is there an optional argument to document.open that specifies the charset? I can't find one!)

* Is this instead a Firefox bug?

All thoughts and ideas appreciated.
Mar 26 '07 #1
2 14849
Follow-up: saving the source of the file in Firefox and looking at it in a hexeditor, it looks like it's actually UTF-16/UCS-2.

Even more strange?
Mar 26 '07 #2
Sorry to jump into your thread, but hey, free bump back up to the top!

I'm having the same problem but trying to use IBM850 character set. On a normal page, I send the following line in the header information (i.e. before the html tag):
Content-type: text/html; charset=IBM850

I can't do this when using Javascripts window.open. Firefox shows the encoding of a javascript popup window to be UTF-8. I've already tried adding the following line inside the HTML that is written to the javascript window:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=IBM850">

This has no effect though. Any non-ASCII IBM850 characters are displayed wrongly in the popup window.
Mar 27 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Agnes | last post: by
2 posts views Thread by Anna Carr | last post: by
2 posts views Thread by Guillermo Rosich Capablanca | last post: by
18 posts views Thread by james | last post: by
44 posts views Thread by Kulgan | last post: by
3 posts views Thread by LiMBi | last post: by
9 posts views Thread by jraul | last post: by
13 posts views Thread by =?Utf-8?B?YXVsZGg=?= | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.