Get the document character encoding in JavaScript

Description

The following code shows how to get the document character encoding.

Example


<!--from w w w . j  ava 2  s  . c o  m-->

<!DOCTYPE HTML>
<html>
<body>
<script>
document.writeln(document.charset);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Get the document character encoding in JavaScript