W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2005

[whatwg] charset attribute of HTMLScriptElement

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 2 May 2005 02:12:59 +0000 (UTC)
Message-ID: <Pine.LNX.4.61.0505020210210.26870@dhalsim.dreamhost.com>
On Mon, 2 May 2005, Toshirou Takahashi wrote:
> > 
> > You can already do this -- just include the correct encoding 
> > information in the Content-Type header for the JS file, as in:
> > 
> >    Content-Type: text/javascript;charset=utf-8
> 
> It is a good method. I also agree and I can do.
> 
> However, how do you do when the user cannot use cgi , .htaccess etc ?

When using systems that are unable of basic compliance with existing Web 
standards, it is possible to include the character encoding in the "type" 
attribute of the <script> element, as follows:

   <script type="text/javascript;charset=utf-8">
    ...
   </script>

However, it should be noted that in most cases HTTP defines that the 
information contained in that attribute is overridden by the information 
in the HTTP headers and thus this is not a reliable method (and would not 
work, for instance, if the server sent back contradictory metadata).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Sunday, 1 May 2005 19:12:59 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:41 UTC