在浏览器中,document文档对象是核心,是window对象的下一级对象。标识整个网页文档中的实际类容,使用document文档对象可以访问HTML页面的基本元素,并可以对元素进行编程,设置元素的属性。
document的title属性的用法:
Var value=docuement.title;
docuement.title="设置的标题文字";
下面是利用document的title属性来设置标题
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>标题栏上的文字逐个显现</title>
<script language="JavaScript">
var showstring="标题栏上的文字逐个显现";
var showHead=0;
function titleShow()
{
var s;
if(showHead<showstring.length)
{
s=showstring.substring(0,showHead);
showHead++;
}
else
{
s=showstring;
showHead=0;
}
window.document.title=s;
setTimeout("titleShow()",200); //每隔200毫秒执行一次titleshow()函数,也就是说每隔200毫秒就输出一个字
}
</script>
</head>
<body οnlοad="titleShow()">
</body>
</html>