Get document title in JavaScript

Description

The following code shows how to get document title.

Example


<!DOCTYPE HTML>
<html>
<body>
<script>
<!--from  ww w  .  j  a  va2  s.  c om-->
document.writeln("title: " + document.title);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Get document title in JavaScript