本文实例讲述了JavaScript实现在标题栏上显示当前日期的方法。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下: <br /> <!--<br /> function writeIt() {<br /> // getDate<br /> var now = new Date();<br /> var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');<br /> var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');<br /> var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();<br /> // quadYear<br /> function y2k(number){return (number < 1000) ? number + 1900 : number;}<br /> // glueIt<br /> today = days[now.getDay()] + " " +<br /> months[now.getMonth()] + ", " +<br /> date + " " +<br /> (y2k(now.getYear())) ;<br /> if(document.all || document.getElementById){ // Browser Check<br /> document.title = today.toString();<br /> }else{<br /> self.status = today.toString(); // Default to status.<br /> }<br /> }<br /> writeIt();<br /> //--><br /> 希望本文所述对大家的javascript程序设计有所帮助。