本文實例講述了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程式設計有所幫助。