charset in window created from javascript

Discussion in 'Javascript' started by Lõrinczy Zsigmond, Dec 4, 2004.

  1. 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?
    Lõrinczy Zsigmond, Dec 4, 2004
    #1
    1. Advertising

  2. 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?

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Dec 4, 2004
    #2
    1. Advertising

  3. Martin Honnen wrote:

    >
    >
    > 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?


    Well if I w.document.write ("Név") (three bytes) and I see "NĂŠv" in
    Page Source (four bytes).
    LÅ‘rinczy Zsigmond, Dec 4, 2004
    #3
  4. Martin Honnen, Dec 4, 2004
    #4
  5. Martin Honnen wrote:
    >
    >
    > Martin Honnen wrote:
    >
    >
    >> I am going to search bugzilla on the view source problem, maybe that
    >> is a known problem.

    >
    >
    > Yes, it is a known problem:
    > https://bugzilla.mozilla.org/show_bug.cgi?id=161778
    >

    Yes it is the same problem. Thank you!
    LÅ‘rinczy Zsigmond, Dec 5, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ulf Heyder
    Replies:
    0
    Views:
    558
    Ulf Heyder
    Oct 16, 2003
  2. jimjim
    Replies:
    12
    Views:
    1,883
    Ron Natalie
    Jun 3, 2005
  3. tom c
    Replies:
    6
    Views:
    496
    tom c
    Sep 6, 2006
  4. KC
    Replies:
    2
    Views:
    127
    Patient Guy
    Dec 12, 2006
  5. optimistx

    javascript charset <> page charset

    optimistx, Aug 14, 2008, in forum: Javascript
    Replies:
    2
    Views:
    260
    optimistx
    Aug 15, 2008
Loading...

Share This Page