How to get and set document title in Javascript
Document titme
document.title
returns the document title, changes the document title.
Example
<!DOCTYPE HTML>
<html>
<body>
<script>
document.writeln("<pre>");
document.writeln("compatMode: " + document.compatMode);
document.writeln("dir: " + document.dir);
document.writeln("domain: " + document.domain);
document.writeln("referrer: " + document.referrer);
document.writeln("title: " + document.title);
document.write("</pre>");
</script>
</body>
</html><!-- w w w . j a v a2 s. c om-->
Change the document title
The following code changes the document title.
<!DOCTYPE HTML>
<html>
<body>
<script>
document.writeln("<pre>");
document.writeln("compatMode: " + document.compatMode);
document.writeln("dir: " + document.dir);
document.writeln("domain: " + document.domain);
document.writeln("referrer: " + document.referrer);
document.writeln("title: " + document.title);
document.write("</pre>");
<!-- w ww .j av a 2 s .c o m-->
document.title = "new title";
</script>
</body>
</html>