charset in window created from javascript

  • Thread starter Lõrinczy Zsigmond
  • Start date
L

Lõrinczy Zsigmond

Hello

I open a window from JavaScript with w=window.open,
write content with w.document.open,w.document.write,
w.document.close. I specified charset with
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-2">
but did not help much.
In Internet Explorer w.document.charset="ISO-8559-2"
after w.document.open solved the problem, but with Mozilla
this do not work. There is a w.document.characterSet, but
this is read only. Mozilla seems forcing UTF-8 - is there a way
to change this?
 
M

Martin Honnen

Lőrinczy Zsigmond wrote:

I open a window from JavaScript with w=window.open,
write content with w.document.open,w.document.write,
w.document.close. I specified charset with
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-2">
but did not help much.
In Internet Explorer w.document.charset="ISO-8559-2"
after w.document.open solved the problem, but with Mozilla
this do not work. There is a w.document.characterSet, but
this is read only. Mozilla seems forcing UTF-8 - is there a way
to change this?

I am not sure I understand the problem, once you are having script
writing to the page you are using JavaScript strings and these allow you
to use all Unicode characters directly or encoded
(String.fromCharCode(unicode), '\udddd')) so character set problems
shouldn't arise.
For instance the following writes the Euro symbol and a German umlaut to
the window just fine with Netscape 7.2:

var text = 'Der Preis ist 200€ über dem Limit.';
var win = window.open('', 'jsWin',
'width=300,height=300,scrollbars,resizable');
win.document.open();
win.document.write('<p>' + text + '<\/p>');
win.document.close();

In what way do you think Mozilla is "forcing UTF-8", how do figure that?
 
L

Lőrinczy Zsigmond

Martin said:
Lőrinczy Zsigmond wrote:




I am not sure I understand the problem, once you are having script
writing to the page you are using JavaScript strings and these allow you
to use all Unicode characters directly or encoded
(String.fromCharCode(unicode), '\udddd')) so character set problems
shouldn't arise.
For instance the following writes the Euro symbol and a German umlaut to
the window just fine with Netscape 7.2:

var text = 'Der Preis ist 200€ über dem Limit.';
var win = window.open('', 'jsWin',
'width=300,height=300,scrollbars,resizable');
win.document.open();
win.document.write('<p>' + text + '<\/p>');
win.document.close();

In what way do you think Mozilla is "forcing UTF-8", how do figure that?

Well if I w.document.write ("Név") (three bytes) and I see "NĂŠv" in
Page Source (four bytes).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top