在使用这个js的时候,日历弹不出来,浏览器报错说 “行 596;char 6;错误 缺少对象;”可是我根本没有596行啊,aspx文件一共才三百多行,汗颜!哪儿去找这一行呢?
主要代码
<head runat="server">
<script language="javascript" type="text/javascript" src="../../js/popcalendar.js"></script></head>
<body>
<form id="form2" action="" runat="server" method="post">
<td align="right" style="height: 33px">Birthday</td>
<td style="height: 33px">
<input type="text" id="txtBirthday" cssclass="select_shorter" runat="server" onclick='popUpCalendar(this, txtBirthday, "yyyy-mm-dd")' /></td>------------------------------------这一行在我的代码中是220行
望高手赐教!谢谢!
主要代码
<head runat="server">
<script language="javascript" type="text/javascript" src="../../js/popcalendar.js"></script></head>
<body>
<form id="form2" action="" runat="server" method="post">
<td align="right" style="height: 33px">Birthday</td>
<td style="height: 33px">
<input type="text" id="txtBirthday" cssclass="select_shorter" runat="server" onclick='popUpCalendar(this, txtBirthday, "yyyy-mm-dd")' /></td>------------------------------------这一行在我的代码中是220行
望高手赐教!谢谢!
function popUpCalendar(ctl,ctl2,format) {
var leftpos=0
var toppos=0 if (bPageLoaded)
{
if ( crossobj.visibility =="hidden" ) {
ctlToPlaceValue = ctl2
dateFormat=format; formatChar = " "
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "/"
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "."
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "-"
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
// invalid date format
formatChar=""
}
}
}
} tokensChanged = 0
if ( formatChar != "" )
{
// use user's date
aData = ctl2.value.split(formatChar) for (i=0;i<3;i++)
{
if ((aFormat[i]=="d") || (aFormat[i]=="dd"))
{
dateSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if ((aFormat[i]=="m") || (aFormat[i]=="mm"))
{
monthSelected = parseInt(aData[i], 10) - 1
tokensChanged ++
}
else if (aFormat[i]=="yyyy")
{
yearSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if (aFormat[i]=="mmm")
{
for (j=0; j<12; j++)
{
if (aData[i]==monthName[j])
{
monthSelected=j
tokensChanged ++
}
}
}
else if (aFormat[i]=="mmmm")
{
for (j=0; j<12; j++)
{
if (aData[i]==monthName2[j])
{
monthSelected=j
tokensChanged ++
}
}
}
}
} if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected))
{
dateSelected = dateNow
monthSelected = monthNow
yearSelected = yearNow
} odateSelected=dateSelected
omonthSelected=monthSelected
oyearSelected=yearSelected aTag = ctl
do {
aTag = aTag.offsetParent;
leftpos += aTag.offsetLeft;
toppos += aTag.offsetTop;
} while(aTag.tagName!="BODY"); crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX
crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY
constructCalendar (1, monthSelected, yearSelected);
crossobj.visibility=(dom||ie)? "visible" : "show" hideElement( 'SELECT', document.getElementById("calendar") );
hideElement( 'APPLET', document.getElementById("calendar") ); bShow = true;
}
else
{
hideCalendar()
if (ctlNow!=ctl) {popUpCalendar(ctl, ctl2, format)}
}
ctlNow = ctl
}
}
以上是popUpcalendar的代码
这句代码应该放在哪里呢?还有我发现了新的问题,在ie中弹不出来,但是在Netscape中能出来,可是老师出现在页面顶端,而不再输入框处,这是什么原因呢?
<head runat="server">
<script language="javascript" type="text/javascript" src="../../js/popcalendar.js" defer="defer"> </script>
</head>
在web.config中添加
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" />,并且要去掉defer="defer",就OK了。