JavaScript Tutorial/Document/title

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

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

<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>
<P>You can change <a href="javascript:changeTitle()">
the &lt;title&gt; element</a> on this page</p>
</body>
</html>


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.



<html>
    <head><title>My Web Page</title></head>
    <script>
    <!--
    document.write("The title of this page is <i>");
    document.write(document.title,"</i>");
    -->
    </script>
    </html>