[whatwg] charset attribute of HTMLScriptElement

Ian Hickson ian at hixie.ch
Sun May 1 19:12:59 PDT 2005


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.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list