<!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=utf-8" /> <title>无标题文档</title> </head> <mce:script type="text/javascript"><!-- function calendar(year, month, date) { var today = new Date(); if (year == '') { year = today.getYear(); if(year < 2000) { year += 1900; } } if (month == '') { month = today.getMonth(); } else { month -= 1; } if (date == '') { date = today.getDate(); } var today1 = new Date(year, month, 1); var y = today1.getYear(); var m = today1.getMonth()+1; var w = today1.getDay(); if (y < 2000) { y += 1900; } var getWeek = new Array( '星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六' ); var week = getWeek[w]; var day = getDays(y, m); var site = 13; document.getElementById('show_y').innerHTML = "<span class='show_font'>"+y+"</span>年<span class='show_font'>"+m+"</span>月<span class='show_font'>"+date+"</span>日"+" "+week; document.getElementById('year').value = y; document.getElementById('month').value = m; for (var i = 0; i < w; i++) {//前面日期无效的部分 document.getElementsByTagName('div')[site].innerHTML = i+1; document.getElementsByTagName('div')[site].style.backgroundColor = '#f8f8f8'; document.getElementsByTagName('div')[site].style.color = '#ddd'; site++; } for (var k = 1; k <= day; k++) {//一个月正常日期现实部分 document.getElementsByTagName('div')[site].innerHTML = k; if( k == date ) { document.getElementsByTagName('div')[site].style.color = 'red'; document.getElementsByTagName('div')[site].style.backgroundColor = '#ccc'; } else { document.getElementsByTagName('div')[site].style.color = '#000'; document.getElementsByTagName('div')[site].style.backgroundColor = '#fff'; } site++; } var no = 1; for (var j = site; j < 55; j++) {//后面日期无效的部分 document.getElementsByTagName('div')[j].style.backgroundColor = '#f8f8f8'; document.getElementsByTagName('div')[j].style.color = '#ddd'; document.getElementsByTagName('div')[j].innerHTML = no; no++; } //return y+'-'+m+'-'+date+week; } function getDays(year, m) { if ( (year%400 == 0 || (year%100 != 0 && year%4 == 0)) && m == 2 ) { return 29; } if( m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) { return 31; } else if( m == 2 ) { return 28; } else { return 30; } } function lastYear(id,id1) { var y = document.getElementById(id1).value; var m = document.getElementById(id).value; y = parseInt(y) - 1; calendar(y, m, ''); } function lastMonth(id,id1) { var m = document.getElementById(id).value; var y = document.getElementById(id1).value; y = parseInt(y); m = parseInt(m); if( m == 1 ) { m = 12; y -= 1; } else { m -= 1; } calendar(y, m, ''); } function nextYear(id,id1) { var y = document.getElementById(id1).value; var m = document.getElementById(id).value; y = parseInt(y) + 1; calendar(y, m, ''); } function nextMonth(id,id1) { var m = document.getElementById(id).value; var y = document.getElementById(id1).value; y = parseInt(y); m = parseInt(m); if( m == 12 ) { m = 1; y += 1; } else { m += 1; } calendar(y, m, ''); } //alert(calendar(1999,8,4)); // --></mce:script> <mce:style><!-- body { font:Arial, Helvetica, sans-serif 12px; color:#000; margin:0 auto; padding:0px; } ul { padding:0px; margin:0px; list-style-type:none; } li { padding:0px; margin:0px; list-style-type:none; } #calendar { width:274px; height:240px; margin:0 auto; padding:0px; margin-top:20px; background:#ccc; } #calendar ul { width:274px; height:210px; } #calendar ul li { width:274px; height:30px; } #calendar ul li input { border:0px; background:none; height:25px; } #calendar ul li div { height:28px; width:37px; border:1px #888 solid; line-height:28px; text-align:center; float:left; background:#f8f8f8; color:#ddd; } #calendar ul li .title { background:#ccc; height:28px; width:37px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:#000; } #calendar ul li .left { background:#ccc; height:28px; width:35px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:#000; } #calendar ul li .l_butt { background:#f8f8f8; height:28px; width:30px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:#000; } #calendar ul li .show_year { background:#f8f8f8; height:28px; width:134px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:blue; font-size:11px; font-weight:bold; } .no_no { height:28px; width:30px; border:1px #888 solid; line-height:28px; text-align:center; float:left; background:#f8f8f8; color:#ddd; } .show_font { font-size:13px; color:red; font-weight:bold; } --></mce:style><style mce_bogus="1">body { font:Arial, Helvetica, sans-serif 12px; color:#000; margin:0 auto; padding:0px; } ul { padding:0px; margin:0px; list-style-type:none; } li { padding:0px; margin:0px; list-style-type:none; } #calendar { width:274px; height:240px; margin:0 auto; padding:0px; margin-top:20px; background:#ccc; } #calendar ul { width:274px; height:210px; } #calendar ul li { width:274px; height:30px; } #calendar ul li input { border:0px; background:none; height:25px; } #calendar ul li div { height:28px; width:37px; border:1px #888 solid; line-height:28px; text-align:center; float:left; background:#f8f8f8; color:#ddd; } #calendar ul li .title { background:#ccc; height:28px; width:37px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:#000; } #calendar ul li .left { background:#ccc; height:28px; width:35px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:#000; } #calendar ul li .l_butt { background:#f8f8f8; height:28px; width:30px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:#000; } #calendar ul li .show_year { background:#f8f8f8; height:28px; width:134px; border:1px #888 solid; line-height:28px; text-align:center; float:left; color:blue; font-size:11px; font-weight:bold; } .no_no { height:28px; width:30px; border:1px #888 solid; line-height:28px; text-align:center; float:left; background:#f8f8f8; color:#ddd; } .show_font { font-size:13px; color:red; font-weight:bold; }</style> <body οnlοad="calendar( '','','' )"> <div id="calendar"> <ul> <li> <div class="left"><input type="button" value="<<" οnclick="lastYear('month','year')"><input type="hidden" id="year" /></div> <div class="l_butt"><input type="button" value="<" οnclick="lastMonth('month','year')"><input type="hidden" id="month" /></div> <div id="show_y" class="show_year"></div> <div class="l_butt"><input type="button" value=">" οnclick="nextMonth('month','year')"></div> <div class="left"><input type="button" value=">>" οnclick="nextYear('month','year')"></div> </li> <li> <div class="title">日</div><div class="title">一</div><div class="title">二</div><div class="title">三</div><div class="title">四</div><div class="title">五</div><div class="title">六</div> </li> <li> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div> </li> <li> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div> </li> <li> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div> </li> <li> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div> </li> <li> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div> </li> <li> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div> </li> </ul> </div> </body> </html>
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
QQ咨询|关于我们|Archiver|手机版|小黑屋|( 辽ICP备15012455号-4 ) Powered by 期权论坛 X3.2 © 2001-2016 期权工具网&期权论坛 Inc.
下载期权论坛手机APP