HTML DOM charset 方法

定义和用法

The charset property sets or returns the character encoding of the target URL.

语法

  1. linkObject.charset=character-encoding

实例

The following example sets the character encoding of the target URL:

  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" id="style1"
  4. href="try_dom_link.css" />
  5. </head>
  6. <body>
  7.  
  8. <script type="text/javascript">
  9. x=document.getElementById("style1");
  10. x.charset="ISO-8859-1";
  11. document.write("Charset=" + x.charset);
  12. </script>
  13.  
  14. </body>
  15. </html>