Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

Javascript >> Document

How can I set the document title?

Visitor Ratings (0) :

Description
The documents title property is read only. You can only set it once. However you can use JavaScript to set its initial value:

<html>
<head>
<script language="JavaScript"><!--
document.write('<title>This is *my* title<\/title>')
//--></script>
</head>
<body>
</body>
</html>

In Internet Explorer 5.x (I haven't tried it in Internet Explorer 4.x yet) you can use:

document.title = "Your new title";

to place the date and time in the title bar, and even to create a real time clock in the title bar by updating the title every second.

For eg.
<script language="JavaScript"><!--
document.write('<title>Date & Time: ' + (new Date()) + '</title>');
//--></script>
Code
Select All
 Rate this Resource