JS写日历
来源:互联网 发布:淘宝申请售后在哪里 编辑:程序博客网 时间:2024/05/19 22:26
<!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"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script language="javascript">var time=new Date();var rz=time.getDate();//22document.write("日 一 二 三 四 五 六 <br/>");var today=time.getDay();var month=time.getMonth();//得到当前月 2time.setDate(1);var xqq=time.getDay();for(i=0;i<xqq;i++){document.write(" ");}var tmp=1;time.setDate(tmp);while(time.getMonth()==month){var cd=time.getDate();if(cd<10){document.write("0");}if(cd==rz){document.write("<font color='red'>"+cd+"</font> ");}else{document.write(cd+" ");}//星期六换行if(time.getDay()==6){document.write("<br/>");}tmp++;time.setDate(tmp);}</script></head><body></body></html>