By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,883 Members | 955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,883 IT Pros & Developers. It's quick & easy.

Character encoding after window.open()

P: 2
Hi!

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  ...."; 
  3.  
  4. newwin = window.open("", "outputwin", "");
  5. newwin.document.write(data);
  6. newwin.document.close();
  7.  
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 (2.0.0.3) "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.

So...

* 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
Share this Question
Share on Google+
2 Replies


P: 2
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

P: 1
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.