A simple calendar code (for:ff1+ ie5+ opr7+) Test _ Time Date

Source: Internet
Author: User
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "lang=" gb2312 "> <pead> <pead> <title> Basic Ca Lendar </title> <meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 "/> <style type=" Text/css "> main {width:200px; border:0px solid black; Text-align:center; }. Month {background-color:black; Font:bold 12px Verdana; Color:white; }. daysofweek {background-color:gray; Font:bold 12px Verdana; Color:white; days {font-size:12px; Font-family:verdana; Color:black; Background-color:lightyellow; padding:2px; }. Days #today {font-weight:bold; color:red; } </style> <script type= "Text/javascript" > Function buildcal (M, y, CM, CH, CDW, CD, brdr) {var mn=[' Januar Y ', ' February ', ' March ', ' April ', ' may ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' December '; var dIM=[31,0,31,30,31,30,31,31,30,31,30,31]; var OD = new Date (y, m-1, 1); DD replaced line to fix date bug when the current is 31st Od.od=od.getday () +1; DD replaced line to fix date bug when the current today is 31st Var todaydate=new date ()//dd added var scanfortoday= (y==to Daydate.getfullyear () && m==todaydate.getmonth () +1)? Todaydate.getdate (): 0//dd added dim[1]= ((od.getfullyear ()%100!=0) && (Od.getfullyear ()%4==0)) | | (Od.getfullyear ()%400==0))? 29:28; var t= ' <div class= "' +cm+ '" ><table class= "' +cm+ '" cols= "7" cellpadding= "0" border= "' +brdr+ '" cellspacing= "0" ><tr> '; t+= ' <td colspan= "7" class= "' +ch+ '" > ' +mn[m-1]+ '-' +y+ ' </td></tr><tr> '; for (s=0;s<7;s++) t+= ' <td class= ' +cdw+ ' > ' + ' Smtwtfs '. substr (s,1) + ' </td> '; t+= ' </tr><tr> '; for (i=1;i<=42;i++) {var x= (i-od.od>=0) && (i-od.od<dim[m-1))? I-od.od+1: '; if (x==scanfortoday)//dd added x= ' <span id= ' Today ' > ' +x+ ' </span> '//dd added t+= ' <td class= ' +cd+ ' > ' +x+ ' </td> '; if (((i)%7==0) && (i<36)) t+= ' </tr><tr> '; Return t+= ' </tr></table></div> '; } </script> </pead> <body> <script type= "Text/javascript" > var todaydate=new Date () var cu Rmonth=todaydate.getmonth () +1; Get current month (1-12) var curyear=todaydate.getfullyear (); Get document.write (buildcal (Curmonth, Curyear, "main", "month", "DaysOfWeek", "Days", 0)); </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.