JavaScript Tutorial/Document/title

Материал из Web эксперт
Перейти к: навигация, поиск

Assign value to the document title (you must have the title tag in your html document)

   <source lang="javascript">

<html> <head> <title>Untitled</title> <script language="javascript" type="text/javascript"> function changeTitle() {

   var newTitle = prompt("A title.", "default title");
   window.document.title = newTitle;

} </script> </head> <body>

You can change <a href="javascript:changeTitle()"> the <title> element</a> on this page

</body> </html></source>


document.title

The title property is a read-only string that specifies the title of the document.

This property is commonly set with the tag.



   <source lang="javascript">

<html>

   <head><title>My Web Page</title></head>
   <script>
   
   </script>
   </html></source>