<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Document</title> <script> //随机显示title var til = new Array(5); til[0] = '第1个标题'; til[1] = '第2个标题'; til[2] = '第3个标题'; til[3] = '第4个标题'; til[4] = '第5个标题'; var indextitle = Math.floor(Math.random()*til.length); //获取一个随机整数 onload=function chaTitle() { var curTitle = til[indextitle]; //获取数组中的指定项 window.document.title+=' - '+curTitle; //更改当前页的标题 } </script> </head> <body> </body> </html>