Jenis pertama: javascript memaparkan kod masa sistem semasa
1 Disember 2015 12:05:08 Selasa
<div id="jnkc"> </div> <script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000); </script>
Jenis kedua: javascript memaparkan kod masa sistem semasa
2015年12月1日 <script language="JavaScript"> <!-- tmpDate = new Date(); date = tmpDate.getDate(); month= tmpDate.getMonth() + 1 ; year= tmpDate.getYear(); document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日"); // --> </script>
Jenis ketiga: javascript memaparkan kod masa sistem semasa
<!-- 时间代码开始 2015-12-1 星期几 --> <SCRIPT language=JavaScript> today=new Date(); function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i]} var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("<font color=#0099ff> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日 ",d[today.getDay()+1],"</font>" ); </SCRIPT> <!-- 时间代码结束 2015-12-1 星期几 -->
Kaedah keempat (serasi dengan Firefox): javascript memaparkan kod masa sistem semasa
<script language="JavaScript" type="text/javascript"> <!-- var enabled = 0; today = new Date(); var day; var date; if(today.getDay()==0) day = " 星期日" if(today.getDay()==1) day = " 星期一" if(today.getDay()==2) day = " 星期二" if(today.getDay()==3) day = " 星期三" if(today.getDay()==4) day = " 星期四" if(today.getDay()==5) day = " 星期五" if(today.getDay()==6) day = " 星期六" date = (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日" + day +""; document.write(date); // --> </script>
Kaedah kelima: javascript memaparkan kod masa sistem semasa
<script language="JavaScript"> <!-- tmpDate = new Date(); date = tmpDate.getDate(); month= tmpDate.getMonth() + 1 ; year= tmpDate.getYear(); document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日"); // --> </script>
Keenam: javascript memaparkan kod masa sistem semasa
<script language="JavaScript"> var isMonth = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); var isDay = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日"); today = new Date () ; Year=today.getYear(); Date=today.getDate(); if (document.all) document.title="今天是: "+Year+"年"+isMonth[today.getMonth()]+Date+"日"+isDay[today.getDay()] </script>
Kod JS untuk memaparkan tarikh dan masa dalam bar tajuk IE
Anda boleh memaparkan masa dan tarikh dalam bar tajuk halaman web anda Ia adalah fungsi yang sangat diperibadikan, sebenarnya, kodnya sangat mudah, anda boleh membacanya dan mudah untuk dihubungi.
网页标题栏显示时间 <script language="JavaScript"> var isMonth = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); var isDay = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日"); today = new Date () ; Year=today.getYear(); Date=today.getDate(); if (document.all) document.title="今天是: "+Year+"年"+isMonth[today.getMonth()]+Date+"日"+isDay[today.getDay()] </script>
Enam javascript memaparkan masa sistem semasa kaedah yang disediakan di atas, kaedah yang paling disukai oleh semua orang, kami boleh membandingkan dengan teliti dan memilih kaedah yang paling sesuai untuk digunakan.