台灣最大程式設計社群網站
線上人數
897
 
會員總數:246134
討論主題:189713
歡迎您免費加入會員
討論區列表 >> ASP >> calendar(月曆) 跑不出來
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
calendar(月曆) 跑不出來
價值 : 50 QP  點閱數:930 回應數:2
樓主

repair168
初學者
432 293
1132 250
發送站內信

大家好:

部內有台用WIN2000 運行的部門網頁,最近把他換到WIN7的SERVER,不過網頁中的calendar卻無法跑出完整畫面,
calendar是由三個檔組成(如下)
=========================================================================================================
(一)calendar.js
var sMon = new Array(12);
sMon[0] = "Jan"
sMon[1] = "Feb"
sMon[2] = "Mar"
sMon[3] = "Apr"
sMon[4] = "May"
sMon[5] = "Jun"
sMon[6] = "Jul"
sMon[7] = "Aug"
sMon[8] = "Sep"
sMon[9] = "Oct"
sMon[10] = "Nov"
sMon[11] = "Dec"

function calendar(t) {
var sPath = "calendar1.htm";
strFeatures = "dialogWidth=206px;dialogHeight=228px;center=yes;help=no";
st = t.value;
sDate = showModalDialog(sPath,st,strFeatures);
t.value = formatDate(sDate, 0);
}

function checkDate(t) {
dDate = new Date(t.value);
if (dDate == "NaN") {t.value = ""; return;}

iYear = dDate.getFullYear()

if ((iYear > 1899)&&(iYear < 1950)) {

sYear = "" + iYear + ""
if (t.value.indexOf(sYear,1) == -1) {
iYear += 100
sDate = (dDate.getMonth() + 1) + "/" + dDate.getDate() + "/" + iYear
dDate = new Date(sDate)
}
}



t.value = formatDate(dDate);
}

function formatDate(sDate) {
var sScrap = "";
var dScrap = new Date(sDate);
if (dScrap == "NaN") return sScrap;

iDay = dScrap.getDate();
iMon = dScrap.getMonth();
iYea = dScrap.getFullYear();

sScrap = iYea + "/" + (iMon + 1) + "/" + iDay ;
return sScrap;
}

=======================================================================================
(二)calendar1.htm

<html>
<head>
<title>Calendar</title>
<script language="JavaScript">
var sTemp
</script>
</head>

<body topmargin="0" leftmargin="0" scroll="no" bgcolor="#c0c0c0">

<table border="0" cellpadding="0" cellspacing="0" width="22">
<tr>
<td>
<OBJECT data=calendar2.htm height=14 id=cal
style="HEIGHT: 160px; LEFT: 0px; TOP: 0px; WIDTH: 200px"
type=text/x-scriptlet width=14 VIEWASTEXT></OBJECT>
</td>
</tr>
<tr>
<td><input type="button" value="關閉/Close" name="cmdClose" style="WIDTH: 200px" ONCLICK="window.close();"></td>
</tr>
</table>

<p>
<script LANGUAGE="JavaScript" FOR="cal" EVENT="onscriptletevent(name,eventdata)">
dateChange(eventdata);
</script>
<script language="JavaScript">
<!--
window.onload = initWindow;
function initWindow() {
window.returnValue = window.dialogArguments;
cal.setDate(window.dialogArguments);
}

function dateChange(sValue) {
window.returnValue = sValue;
window.close();
}

// -->
</script></p>
</body>
</html>
========================================================================================================


(三)calendar2.htm
<html>

<head>
<title>Calendar</title>
<style>
<!--
.DayN { font-family: Arial; font-size: 11px; background-color: rgb(192,192,192); color: rgb(0,0,0); font-weight: bold; text-align: center; vertical-align: middle; border: 2px solid rgb(192,192,192) }
.DayU { font-family: Arial; font-size: 11px; background-color: rgb(128,128,128); color: rgb(255,255,255); font-weight: bold; text-align: center; vertical-align: middle; border: 2px outset rgb(255,255,255) }
.DayD{ font-family: Arial; font-size: 11px; background-color: rgb(255,255,255); color: rgb(0,0,0); font-weight: bold; text-align: center; vertical-align: middle; border: 2px inset rgb(255,255,255) }
.WeekDay{ font-family: Arial; font-size: 11px; background-color: #0000ff; color: rgb(255,255,255); font-weight: bold; text-align: center; vertical-align: middle; border-left: 1px solid rgb(255,255,255); border-right: 1px solid rgb(255,255,255); border-top: 1px solid rgb(255,255,255) }
.WeekEnd{ font-family: Arial; font-size: 11px; background-color: rgb(255,0,0); color: rgb(255,255,255); font-weight: bold; text-align: center; vertical-align: middle; border-left: 1px solid rgb(255,255,255); border-right: 1px solid rgb(255,255,255); border-top: 1px solid rgb(255,255,255) }
.ArrowN{ font-family: Arial; font-size: 13px; background-color: rgb(128,128,128); color: rgb(255,255,255); font-weight: bold; text-align: center; vertical-align: middle; border: 2px solid rgb(128,128,128) }
.ArrowU{ font-family: Arial; font-size: 13px; background-color: rgb(128,128,128); color: rgb(255,255,255); font-weight: bold; text-align: center; vertical-align: middle; border: 2px outset rgb(255,255,255) }
.ArrowD{ font-family: Arial; font-size: 13px; background-color: rgb(192,192,192); color: rgb(255,255,255); font-weight: bold; text-align: center; vertical-align: middle; border: 2px inset rgb(255,255,255) }
.DateSelect{ font-family: Arial; font-size: 11px; background-color: rgb(192,192,192); font-weight: bold; text-align: right }
-->
</style>
</head>

<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0">

<table border="0" cellpadding="0" cellspacing="0"
style="font-size: 11px; cursor: hand; background-color: rgb(192,192,192); border: 1px solid rgb(0,0,0)"
id="tblCal" width="100%" height="100%" OnSelectStart="return false;">
<tr>
<td align="center" bgcolor="#808080" id="celBack" class="ArrowN">&lt;</td>
<td align="center" style="vertical-align: middle" id="celMonth" colspan="5"><table
border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="68"><div style="clip:rect(2,70,16,2); position:absolute; top:3px"><p><select
name="selMonth" size="1" class="DateSelect" style="text-align: right"
ONCHANGE="selMonthYear();">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select></p>
</div></td>
<td width="30"><div style="clip:rect(2,28,16,2); position:absolute; top:3px"><p><select
name="selYear" size="1" class="DateSelect" style="text-align: right"
ONCHANGE="selMonthYear();">
</select></p>
</div></td>
</tr>
</table>
</td>
<td align="center" bgcolor="#808080" id="celNext" class="ArrowN">&gt;</td>
</tr>
<tr>
<td align="center"
style="vertical-align: middle; background-color: rgb(255,0,0); color: rgb(255,255,255)"
width="14%" class="WeekEnd">S</td>
<td align="center" style="vertical-align: middle" width="14%" class="WeekDay">M</td>
<td align="center" style="vertical-align: middle" width="14%" class="WeekDay">T</td>
<td align="center" style="vertical-align: middle" width="14%" class="WeekDay">W</td>
<td align="center" style="vertical-align: middle" width="14%" class="WeekDay">T</td>
<td align="center" style="vertical-align: middle" width="14%" class="WeekDay">F</td>
<td align="center"
style="vertical-align: middle; background-color: #ff0000; color: #ffffff" width="14%"
class="WeekEnd">S</td>
</tr>
<tr>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d1"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d2"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d3"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d4"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d5"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d6"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d7"></td>
</tr>
<tr>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d8"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d9"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d10"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d11"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d12"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d13"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d14"></td>
</tr>
<tr>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d15"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d16"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d17"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d18"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d19"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d20"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d21"></td>
</tr>
<tr>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d22"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d23"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d24"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d25"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d26"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d27"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d28"></td>
</tr>
<tr>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d29"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d30"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d31"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d32"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d33"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d34"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d35"></td>
</tr>
<tr>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d36"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d37"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d38"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d39"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d40"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d41"></td>
<td align="center" style="vertical-align: middle" class="DayN" width="14%" id="d42"></td>
</tr>
</table>

<p><script language="JavaScript"><!--
var dCurDate = "";
var objTemp;

window.onload = initWindow;
window.onerror = doError;
document.onmouseover = raiseCel;
document.onmouseout = sinkCel;
document.onmousedown = mdCel;
document.onmouseup = muCel;

function doError() {
alert(arguments[0]);
}


function initWindow() {
var dNow = new Date();
setDateSelect();
updateCal(dNow);
displayMonthYear(dNow);
}


function public_setDate(sDate) {
dCurDate = "";
objTemp = "";
var dNow = new Date(sDate);
dCurDate = dNow;
if (dNow == "NaN") {dNow = new Date(); dCurDate = "";}

displayMonthYear(dNow);
updateCal(dNow);
}

function setDay(sDay) {
sMonth = selMonth.options[selMonth.selectedIndex].text;
sYear = selYear.value
window.external.raiseEvent("ondatechange",sMonth + " " + sDay + ", " + sYear);
}

function displayMonthYear(dDate) {
iYear = dDate.getFullYear();
selYear.value = iYear;
if (selYear.value == "")
{
objNewOpt = document.createElement("OPTION");
objNewOpt.text = iYear;
objNewOpt.value = iYear;
if (iYear > parseInt(selYear.options[0].value)) iPos = 0;
else iPos = selYear.options.length + 1;
selYear.options.add(objNewOpt,iPos);
selYear.value = iYear;
}
selMonth.selectedIndex = dDate.getMonth();
}

function selMonthYear() {
dDate = new Date(selYear.value, selMonth.selectedIndex, 1);
updateCal(dDate);
}

function setDateSelect() {
dNow = new Date();
iScrap = dNow.getFullYear();
for (i=0; i<5; i++)
{
objNewOpt = document.createElement("OPTION");
objNewOpt.text = (iScrap - i);
objNewOpt.value = (iScrap - i);
selYear.options.add(objNewOpt);
}
}

function raiseCel() {
objItem = window.event.srcElement;
if (objItem.className == "DayN")
if (objItem.innerText != "") objItem.className = "DayU";
if (objItem.className == "ArrowN") objItem.className = "ArrowU";
}

function sinkCel() {
objItem = window.event.srcElement;
if (objItem.className == "DayU") objItem.className = "DayN";
if (objItem.className == "ArrowU") objItem.className = "ArrowN";
}

function mdCel() {
objTemp = "";
sCel = window.event.srcElement;
if (sCel.className == "DayU") {sCel.className = "DayD"; objTemp = sCel;}
if (sCel.className == "ArrowU") sCel.className = "ArrowD";
}

function muCel() {
sCel = window.event.srcElement;
if (sCel.className == "ArrowD")
{
sCel.className = "ArrowU";
if (sCel.id == "celBack")
{
dDate = dateAdd("m", -1, new Date(selYear.value, selMonth.selectedIndex, 1));
displayMonthYear(dDate);
updateCal(dDate);
}
if (sCel.id == "celNext")
{
dDate = dateAdd("m", 1, new Date(selYear.value, selMonth.selectedIndex, 1));
displayMonthYear(dDate);
updateCal(dDate);
}
}
if (sCel.className == "DayD") setDay(sCel.innerText);
if (objTemp != "") objTemp.className = "DayN";
}

function updateCal(dDate) {
iMonth = dDate.getMonth();
iYear = dDate.getFullYear();
iDay = dDate.getDate();

dStart = new Date(iYear, iMonth, 1);
dEnd = dateAdd("m", 1, dStart);

iDays = dateDiff("d", dStart, dEnd);
iStartDay = (dStart.getDay() + 1);

for (i = 1; i < 43; i++) {
sScrap = "d" + i
objItem = document.all[sScrap];
if (objItem.className == "DayD") objItem.className = "DayN";

if ((i < iStartDay) || ((i - iStartDay + 1) > iDays)) objItem.innerText = "";
else objItem.innerText = (i - iStartDay + 1);
}

if (dCurDate != "")
if ((dCurDate.getMonth() == dDate.getMonth()) && (dCurDate.getFullYear() == dDate.getFullYear()))
document.all("d" + (iStartDay - 1 + dCurDate.getDate())).className = "DayD";
}

function dateAdd(sInterval, iNumber, dDate) {
dTemp = new Date(dDate);
if (dTemp == "NaN") dTemp = new Date();
switch (sInterval) {
case "s" :
return new Date(Date.parse(dTemp) + (1000 * iNumber));
case "n" :
return new Date(Date.parse(dTemp) + (60000 * iNumber));
case "h" :
return new Date(Date.parse(dTemp) + (3600000 * iNumber));
case "d" :
return new Date(Date.parse(dTemp) + (86400000 * iNumber));
case "w" :
return new Date(Date.parse(dTemp) + ((86400000 * 7) * iNumber));
case "m" :
return new Date(dTemp.getFullYear(), (dTemp.getMonth()) + iNumber, dTemp.getDate());
case "y" :
return new Date((dTemp.getFullYear() + iNumber), dTemp.getMonth(), dTemp.getDate());
}
}

function dateDiff(sInterval, dStart, dEnd) {
dStart = new Date(dStart);
if (dStart == "NaN") dStart = new Date();
dEnd = new Date(dEnd);
if (dEnd == "NaN") dEnd = new Date();
switch (sInterval) {
case "s" :
return parseInt((Date.parse(dEnd) - Date.parse(dStart)) / 1000);
case "n" :
return parseInt((Date.parse(dEnd) - Date.parse(dStart)) / 60000);
case "h" :
return parseInt((Date.parse(dEnd) - Date.parse(dStart)) / 3600000);
case "d" :
iScrap = (Date.parse(dEnd) - Date.parse(dStart)) / 86400000
iScrap = iScrap + .1
return parseInt(iScrap);
case "w" :
return parseInt((Date.parse(dEnd) - Date.parse(dStart)) / (86400000 * 7));
case "m" :
return (dEnd.getMonth() - dStart.getMonth());
case "y" :
return (dEnd.getFullYear() - dStart.getFullYear());
}
}

// --></script></p>
</body>
</html>
================================================================================================================

我是用<input name="Limit_Date" OnClick="calendar(Limit_Date)" size=9 value="<%=Date()%>" style="color: #0000FF">,
結果有跑出calendar圖框,可是卻沒有裡面的日期選項

這程式在win2000 server運作是正常的,請問是甚麼問題?

謝謝!


搜尋相關Tags的文章: [ calendar ] ,
本篇文章發表於2017-01-19 04:44
1樓
作者回應

repair168
檢舉此回應
我找到答案了,後來把ie/工具/相容性檢視設定/加入此網址後 就沒問題了,給大家參考!
本篇文章回覆於2017-01-21 17:12
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
2樓
回應

迷路
捐贈 VP 給 迷路 檢舉此回應
咦!樓主的方法針對的是瀏覽器而非是主機
也就是說每台瀏覽網頁的電腦都得做同樣的設定
一般來說不會建議用這樣的方法來做為解決手段
如果說用這樣的方法可以解決
代表的意思就是寫法太舊,新版的瀏覽器不支援
通常會建議更新寫法
本篇文章回覆於2017-01-23 09:38
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.