function drawCal(firstDay,lastDate,date,monthName,year)
{
//constant table settings
var headerHeight=50 //height of the table's beader cell
var border=2 //3D height of table'border
var cellspacing=4 //widthof table's border
var headerColor="midnightblue" //colorof table's header
var headerSize="+3" //size of tables header font
var colWidth=60 //widthof columns in table
var dayCellHeight=25 //heigth of cells containing days of the week
var dayColor="darkblue" //color of font representing week days
var cellHeight=40 //height of cells representing dates in the calendar
var timeColor="purple" //color of font representing current time
var todayColor="red"
//create basic table structure
// var text="" //initialize accumulative variable to empty string
// text+='<input type=text name=timeselect id=timeselect size=50 style="position:relative;top:-3px;left:375px;" >'
// text+='<input type=button id=btnselect size=2 style="position:relative;top:-3px;left:375px;">'
text+='<CENTER>'
text+='<TABLE BORDER='+border+' CELLSPACING='+cellspacing+'>' //table settings
//text+='<tr height=20px><td colspan=7><input type=text name=timeselect id=timeselect size=50></td></tr>'
text+='<Tr HEIGHT='+headerHeight+'>' //create table header cell
text+='<td colspan=2 height=100% align=lift onclick="preMonth()" style="cursor:pointer">上月</td>'
text+='<td colspan=3 height=100%> <FONT COLOR="'+headerColor+'" SIZE='+headerSize+'>' //set font for table header
text+=monthName+''+year
text+='</FONT></td>' //close table header's font setting
text+='<td colspan=2 height=100% align=right><a href='+nextMonth()+'>下月</a></td>'
text+='</Tr>' //close header cell
//variables to hold constant settings
var openCol='<TD WIDTH='+colWidth+'HEIGHT='+dayCellHeight+'>'
openCol+='<FONT COLOR="'+dayColor+'">'
var closeCol='</FONT></TD>'
//create array of abbreviated day names
//得到星期几的名称
var weekDay=new Array(8)
weekDay[0]="星期天";
weekDay[1]="星期一";
weekDay[2]="星期二";
weekDay[3]="星期三";
weekDay[4]="星期四";
weekDay[5]="星期五";
weekDay[6]="星期六";
//create first row of table to set column width and specitfy week day
text+='<TR ALIGN="center" VALIGN="center">'
for(var dayNum=0;dayNum<7;++dayNum)
{
text+=openCol+weekDay[dayNum]+closeCol
}
text+='</TR>'
//declaration and initialization of two variables to help with tables
var digit =1
var curCell=1
//将日期摆放在日历上
var rownum=Math.ceil((lastDate+firstDay-1)/7);
for(var row=1;row<=rownum;++row)
{
text+='<TR ALIGN="right" VALIGN="top">'
for(var col=1;col<=7;++col)
{
if(digit>lastDate)
{
break
}
if(curCell<firstDay)
{
text+='<TD></TD>'
curCell++
}
else
{
if(digit==date) //current cell represent today's date
{
text+='<TD HEIGHT="'+cellHeight+'" onclick=showTime('+digit+') style="cursor:pointer">'
text+='<FONT COLOR="'+todayColor+'">'
text+=digit
text+='</FONT><BR>'
text+='<FONT COLOR="'+timeColor+'"SIZE=2>'
text+='<CENTER>'+getTime()+'</CENTER>'
text+='</FONT>'
text+='</TD>'
}
else{
text+='<TD HEIGHT='+cellHeight+' onclick=showTime('+digit+') style="cursor:pointer">'+digit+'</TD>'
}
digit++
}
}
text+='</TR>'
}
//close all basic table tags
text+='</TABLE>'
text+='</CENTER>'
document.all.tempDiv.innerHTML = text
}
{
//constant table settings
var headerHeight=50 //height of the table's beader cell
var border=2 //3D height of table'border
var cellspacing=4 //widthof table's border
var headerColor="midnightblue" //colorof table's header
var headerSize="+3" //size of tables header font
var colWidth=60 //widthof columns in table
var dayCellHeight=25 //heigth of cells containing days of the week
var dayColor="darkblue" //color of font representing week days
var cellHeight=40 //height of cells representing dates in the calendar
var timeColor="purple" //color of font representing current time
var todayColor="red"
//create basic table structure
// var text="" //initialize accumulative variable to empty string
// text+='<input type=text name=timeselect id=timeselect size=50 style="position:relative;top:-3px;left:375px;" >'
// text+='<input type=button id=btnselect size=2 style="position:relative;top:-3px;left:375px;">'
text+='<CENTER>'
text+='<TABLE BORDER='+border+' CELLSPACING='+cellspacing+'>' //table settings
//text+='<tr height=20px><td colspan=7><input type=text name=timeselect id=timeselect size=50></td></tr>'
text+='<Tr HEIGHT='+headerHeight+'>' //create table header cell
text+='<td colspan=2 height=100% align=lift onclick="preMonth()" style="cursor:pointer">上月</td>'
text+='<td colspan=3 height=100%> <FONT COLOR="'+headerColor+'" SIZE='+headerSize+'>' //set font for table header
text+=monthName+''+year
text+='</FONT></td>' //close table header's font setting
text+='<td colspan=2 height=100% align=right><a href='+nextMonth()+'>下月</a></td>'
text+='</Tr>' //close header cell
//variables to hold constant settings
var openCol='<TD WIDTH='+colWidth+'HEIGHT='+dayCellHeight+'>'
openCol+='<FONT COLOR="'+dayColor+'">'
var closeCol='</FONT></TD>'
//create array of abbreviated day names
//得到星期几的名称
var weekDay=new Array(8)
weekDay[0]="星期天";
weekDay[1]="星期一";
weekDay[2]="星期二";
weekDay[3]="星期三";
weekDay[4]="星期四";
weekDay[5]="星期五";
weekDay[6]="星期六";
//create first row of table to set column width and specitfy week day
text+='<TR ALIGN="center" VALIGN="center">'
for(var dayNum=0;dayNum<7;++dayNum)
{
text+=openCol+weekDay[dayNum]+closeCol
}
text+='</TR>'
//declaration and initialization of two variables to help with tables
var digit =1
var curCell=1
//将日期摆放在日历上
var rownum=Math.ceil((lastDate+firstDay-1)/7);
for(var row=1;row<=rownum;++row)
{
text+='<TR ALIGN="right" VALIGN="top">'
for(var col=1;col<=7;++col)
{
if(digit>lastDate)
{
break
}
if(curCell<firstDay)
{
text+='<TD></TD>'
curCell++
}
else
{
if(digit==date) //current cell represent today's date
{
text+='<TD HEIGHT="'+cellHeight+'" onclick=showTime('+digit+') style="cursor:pointer">'
text+='<FONT COLOR="'+todayColor+'">'
text+=digit
text+='</FONT><BR>'
text+='<FONT COLOR="'+timeColor+'"SIZE=2>'
text+='<CENTER>'+getTime()+'</CENTER>'
text+='</FONT>'
text+='</TD>'
}
else{
text+='<TD HEIGHT='+cellHeight+' onclick=showTime('+digit+') style="cursor:pointer">'+digit+'</TD>'
}
digit++
}
}
text+='</TR>'
}
//close all basic table tags
text+='</TABLE>'
text+='</CENTER>'
document.all.tempDiv.innerHTML = text
}
解决方案 »
- 求大神!微博那种屏幕靠上方名片卡就在下浮出,屏幕靠下方名片卡就在上浮出的效果怎么做啊?
- jquery的filetree怎样才能自动收起节点?
- JS 有人会用js写出用回车键替代tab,兼容firefox,遇到按钮提交
- 不赋值,请问js怎么申请全局变量?
- 【【如何将右下角弹窗位置固定,而不随滚动条滚动???】】
- document.text 的用法
- alert()语句在本机失效(即弹不出窗口),问本机IE有何问题?
- 100分!!!层中表单聚焦问题?高手进!
- 晕倒嘞,如何安装一个ACTIVEX控件?是不是copy过去注册一下就可以了?
- 这行for循环代码怎么理解?
- insertRow多行后,点击事件传值问题立结
- 有高手研究过mozilla的js引擎吗?
var curr_month = getselectedMonth();
var curr_year = getselectedYear();
if(curr_month <= 0){
curr_month = 11;
curr_year--;
}
else curr_month--; var url = setUrlParam(document.location.href,'year',curr_year);
url = setUrlParam(url,'month',curr_month);
return url;
}
楼主在preMonth里加上alert()试试
href="javascript:xxx()"
这样的写法本身肯定是没问题的.
var curr_month = getselectedMonth();
var curr_year = getselectedYear();
if(curr_month <= 0){
curr_month = 11;
curr_year--;
}
else curr_month--; var url = setUrlParam(document.location.href,'year',curr_year);
url = setUrlParam(url,'month',curr_month);
return url;
/*var now=new Date()
var monthName=getMonthName(curr_month)
var date=now.getDate()
now = null
var firstDayInstance=new Date(curr_year,curr_month,1)
var firstDay=firstDayInstance.getDay()
firstDayInstance=null
window.alert("premonth")
window.alert(curr_month)
var days=getDays(curr_month,curr_year)
drawCal(firstDay+1,days,date,monthName,(curr_year<100)?1900+curr_year:curr_year)
*/
}function getselectedMonth(){
var url = document.location.href;
var month = getUrlParam(url,"month");
if( month == ""){
var now = new Date();
month = now.getMonth();
}
window.alert("getselectedMonth")
window.alert(month)
return month;
}function getselectedYear(){
var url = document.location.href;
var year = getUrlParam(url,"year");
if( year == ""){
var now = new Date();
year = now.getYear();
}
window.alert("year")
return year;
}function getUrlParam(url, param)
{
var re = new RegExp("(\\\?|&)" + param + "=([^&]+)(&|$)", "i");
var m = url.match(re);
if (m)
return m[2];
else
return '';
}
function setUrlParam(url, param, v)
{
var re = new RegExp("(\\\?|&)" + param + "=([^&]+)(&|$)", "i");
var m = url.match(re);
if (m)
{
return (url.replace(re, function($0, $1, $2) { return ($0.replace($2, v)); } ));
}
else
{
if (url.indexOf('?') == -1)
return (url + '?' + param + '=' + v);
else
return (url + '&' + param + '=' + v);
}
}