一段关于日历的js 问题是在360极速模式下 对话框,无法弹出,而在兼容模式下,部分电脑年份正确,部分电脑年份错误 悬赏3元 已结束
<p>php代码 引用</p><p><script src="riqi.js" language="javascript"></script>
</p><p><br></p><p>其中 riqi.js 如下:</p><pre>// JavaScript Document
function loadCalendar(field)
{
var rtn = window.showModalDialog("../inc/calender.php","","dialogWidth:340px;dialogHeight:280px;status:no;help:no;scrolling=no;scrollbars=no");
if(rtn!=null)
field.value=rtn;
return;
}</pre><p><br></p><p>而calender.php 文件 如下:</p><p><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</p><p><script language=javascript>
</p><p><!--
</p><p> var monthNames = new Array ( "", "1","2","3","4","5","6","7", "8", "9", "10", "11", "12" );
</p><p> var endDay = new Array ( 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
</p><p> var dayNow = 0;
</p><p> var monthNow = 0;
</p><p> var yearNow = 0;
</p><p> function load ( form ) {
</p><p> set_month_year_now ();
</p><p> var found = false;
</p><p> for ( var month=0; month<form.monthList.length; month++ )
</p><p> if ( form.monthList[month].text == monthNames[monthNow] ) {
</p><p> form.monthList[month].selected = true;
</p><p> found = true;
</p><p> }
</p><p> if ( !found) {
</p><p> error ();
</p><p> return;
</p><p> }
</p><p> var found = false;
</p><p> for ( var year=0; year<form.yearList.length; year++ )
</p><p> if ( form.yearList[year].text == yearNow ) {
</p><p> form.yearList[year].selected = true;
</p><p> found = true;
</p><p> }
</p><p> if ( !found) {
</p><p> error ();
</p><p> return;
</p><p> }
</p><p> display_month ( form );
</p><p> }
</p><p> function preceding_month ( form ) {
</p><p> var month_selected = form.monthList.selectedIndex;
</p><p> var year_selected = form.yearList.selectedIndex;
</p><p> if ( !month_selected && !year_selected ) {
</p><p> error ();
</p><p> return;
</p><p> }
</p><p> if ( month_selected > 0 )
</p><p> month_selected --;
</p><p> else {
</p><p> month_selected = 11;
</p><p> year_selected --;
</p><p> }
</p><p> form.monthList[month_selected].selected = true;
</p><p> form.yearList[year_selected].selected = true;
</p><p> display_month ( form );
</p><p> }
</p><p> function following_month ( form ) {
</p><p> var month_selected = form.monthList.selectedIndex;
</p><p> var year_selected = form.yearList.selectedIndex;
</p><p> if ( month_selected >= ( form.monthList.length - 1 ) && year_selected >= ( form.yearList.length - 1 ) ) {
</p><p> error ();
</p><p> return;
</p><p> }
</p><p> if ( month_selected < 11 )
</p><p> month_selected ++;
</p><p> else {
</p><p> month_selected = 0;
</p><p> year_selected ++;
</p><p> }
</p><p> form.monthList[month_selected].selected = true;
</p><p> form.yearList[year_selected].selected = true;
</p><p> display_month ( form );
</p><p> }
</p><p> function set_month_year_now () {
</p><p> var form = document.calendar;
</p><p> var now = new Date ();
</p><p> monthNow = now.getMonth () + 1;
</p><p> yearNow = now.getYear ();
</p><p> dayNow = now.getDate();
</p><p> yearNow = ( yearNow < 100 ) ? yearNow + 1900 : yearNow;
</p><p> var count = 0
</p><p> for (var i = yearNow-103; i < yearNow + 50; i++) {
</p><p> eval("form.yearList.options[count] = new Option('"+i+"', '"+i+"')");
</p><p> count++;
</p><p> }
</p><p> form.yearList.selectedIndex = 103;
</p><p> form.yearList.length = count;
</p><p> }
</p><p> function error () {
</p><p> alert ( "超出范围!" );
</p><p> }
</p><p> function display_month ( form )
</p><p> {
</p><p> var month = form.monthList.selectedIndex + 1;
</p><p> var year = parseInt ( form.yearList.options[ form.yearList.selectedIndex].text );
</p><p> var start_day = start_day_in_month ( year, month );
</p><p> var count = 0;
</p><p> for ( var row=0; row<6; row++) {
</p><p> for ( var col=0; col<7; col++ )
</p><p> {
</p><p> if ( row == 0 && col < ( start_day - 1 ) )
</p><p> var day = "";
</p><p> else if ( count < endDay[month] )
</p><p> day = ++count;
</p><p> else
</p><p> day = "";
</p><p> form.dayBox[(row7)+col].style.display = "";
</p><p> form.dayBox[(row7)+col].style.color = "black";
</p><p> if (day == "") {
</p><p> form.dayBox[(row7)+col].style.display = "none";
</p><p> } else {
</p><p> form.dayBox[(row7)+col].value = day;
</p><p> if (col%7 == 0) form.dayBox[(row7)+col].style.color = "red";
</p><p> if (yearNow == year && monthNow == month && dayNow == day) form.dayBox[(row7)+col].style.color = "blue";;
</p><p> }
</p><p> }
</p><p> }
</p><p> }
</p><p> function start_day_in_month ( year, month ) {
</p><p> var day, daynum, ndays, mnum;
</p><p> sday = start_day_in_year ( year );
</p><p> endDay[2] = ( year % 4 ) ? 28 : 29;
</p><p> if ( month == 1 )
</p><p> daynum = sday;
</p><p> else {
</p><p> ndays = sday;
</p><p> for ( mnum=2; mnum<month+1; mnum++ )
</p><p> ndays = ndays + endDay[mnum-1];
</p><p> daynum = ndays % 7;
</p><p> }
</p><p> daynum = (!daynum) ? 7 : daynum;
</p><p> return (daynum);
</p><p> }
</p><p> function start_day_in_year ( year ) {
</p><p> var y, m, d;
</p><p> var n;
</p><p> y = year - 1; m = 13; d = 1;
</p><p> n = d + 2 m + ( Math.floor ( ( 0.6 + (m + 1) ) ) + y );
</p><p> n = n + Math.floor ( ((y / 4) - Math.floor ( (y / 100 ) ) + Math.floor ( ( y / 400 ) ) ) ) + 2 ;
</p><p> n = Math.floor ( ( (n / 7 - Math.floor ( (n / 7) ) ) 7 + 0.5 ) );
</p><p> return (n+1);
</p><p> }
</p><p> function CheckDate(strDay) {
</p><p> var docFrm = document.calendar;
</p><p> var choice_daynum = 0;
</p><p> var current_daynum = 0;
</p><p> var day_temp;
</p><p> if (strDay != "") {
</p><p> var strY = docFrm.yearList.value;
</p><p> var strM = docFrm.monthList.value;
</p><p> var curr_y = new String(yearNow);
</p><p> var curr_m = new String(monthNow);
</p><p> var curr_d = new String(dayNow);
</p><p> if (curr_m.length == 1) curr_m = "0"+curr_m;
</p><p> if (curr_d.length == 1) curr_d = "0"+curr_d;
</p><p> current_daynum = new Number(curr_y + curr_m + curr_d) ;
</p><p> if (strM.length == 1) strM = "0"+strM;
</p><p> if (strDay.length == 1) strDay = "0"+strDay;
</p><p> choice_daynum = new Number(strY + strM + strDay);
</p><p> parent.window.returnValue = strY+"-"+strM+"-"+strDay; //将选择的日期传递到父窗口中
</p><p> parent.window.close();
</p><p> }
</p><p> return false;
</p><p> }
</p><p>-->
</p><p></script>
</p><p><body onLoad="load(document.calendar)" topmargin="0">
</p><p><center>
</p><p> <form name="calendar">
</p><p> <table border="0" cellpadding="0" cellspacing="0">
</p><p> <tr>
</p><p> <td colspan="3" height="24"></td>
</p><p> </tr>
</p><p> <tr>
</p><p> <td width="205" nowrap="nowrap" align="right"><select name="yearList" onChange="display_month(this.form)">
</p><p> </select>
</p><p> </td>
</p><p> <td width="65" nowrap="nowrap" align="left"><select name="monthList" size="1" onChange="display_month(this.form)">
</p><p> <?php for($i=1;$i<=12;$i++){ ?>
</p><p> <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
</p><p> <?php } ?>
</p><p> </select>
</p><p> </td>
</p><p> <td width="10"></td>
</p><p> </tr>
</p><p> <tr>
</p><p> <td colspan="3" height="6"></td>
</p><p> </tr>
</p><p> <tr>
</p><p> <td colspan="3"><table border="0" cellpadding="1" cellspacing="0" align="center">
</p><p> <tr>
</p><p> <td bgcolor="#82664F"><table border="0" cellpadding="0" cellspacing="0">
</p><p> <tr bgcolor="#82664F" height="18">
</p><p> <td width="31" align="center" nowrap="nowrap"><font color="#FF0000">日</font></td>
</p><p> <td width="31" align="center" nowrap="nowrap">一</td>
</p><p> <td width="31" align="center" nowrap="nowrap">二</td>
</p><p> <td width="31" align="center" nowrap="nowrap">三</td>
</p><p> <td width="31" align="center" nowrap="nowrap">四</td>
</p><p> <td width="31" align="center" nowrap="nowrap">五</td>
</p><p> <td width="31" align="center" nowrap="nowrap">六</td>
</p><p> </tr>
</p><p> <?php for($r=0;$r<=5;$r++){ ?>
</p><p> <tr bgcolor="#ffffff" height="18">
</p><p> <?php for($d=0;$d<=6;$d++){ ?>
</p><p> <td align="center"><input type="text" size="2" name="dayBox" readOnly onClick="javascript:CheckDate(this.value);" onMouSEOver="this.style.background='#9966FF'" onmouSEOut="this.style.background='white'">
</p><p> </td>
</p><p> <?php } ?>
</p><p> </tr>
</p><p> <?php } ?>
</p><p> </table></td>
</p><p> </tr>
</p><p> </table></td>
</p><p> </tr>
</p><p> </table>
</p><p> </form>
</p><p></center>
</p><p></body></p><p><br></p><p>现在问题是:</p><p>1、360兼容模式下 ,日期 中年份 跳出来 显示不正确,部分电脑完整,部分电脑不完整</p><p><br></p><p><br></p><p>而部分电脑正确</p><p><br></p><p><br></p><p>如何修改 才能 都正确?</p><p>2、怎么修改 才能在极速模式下正常弹出?</p><p>求详细修改地方。本人js小白。修改代码,可以直接指出来 改成什么吗?</p><p><br></p>