找回密码

碧海潮声大学生网

查看: 724|回复: 7
打印 上一主题 下一主题

〖灌水〗请教这段代码怎么使用

[复制链接]
跳转到指定楼层
1#
发表于 2006-12-16 22:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我把它保存为网页文件,打开后怎么只是空白

<SCRIPT language=JavaScript><!--                 
function CalConv()                 
{                 
      FIRSTYEAR = 1998;                 
LASTYEAR = 2031;                 
                 
today = new Date();                 
SolarYear = today.getFullYear();                 
SolarMonth = today.getMonth() + 1;                 
SolarDate = today.getDate();                 
Weekday = today.getDay();                 
                 
LunarCal = [                 
  new tagLunarCal( 27,  5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),                 
  new tagLunarCal( 46,  0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 88 */                 
  new tagLunarCal( 35,  0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 89 */                 
  new tagLunarCal( 23,  4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 42,  0, 1,  4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 31,  0, 2,  9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),                 
  new tagLunarCal( 21,  2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 93 */                 
  new tagLunarCal( 39,  0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 28,  7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),                 
  new tagLunarCal( 48,  0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),                 
  new tagLunarCal( 37,  0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 97 */                 
  new tagLunarCal( 25,  5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),                 
  new tagLunarCal( 44,  0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),                 
  new tagLunarCal( 33,  0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 22,  4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 101 */                 
  new tagLunarCal( 40,  0, 1,  2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),                 
  new tagLunarCal( 30,  9, 2,  7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 49,  0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 38,  0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 105 */                 
  new tagLunarCal( 27,  6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),                 
  new tagLunarCal( 46,  0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),                 
  new tagLunarCal( 35,  0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),                 
  new tagLunarCal( 24,  4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 109 */                 
  new tagLunarCal( 42,  0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 31,  0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),                 
  new tagLunarCal( 21,  2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),                 
  new tagLunarCal( 40,  0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 113 */                 
  new tagLunarCal( 28,  6, 2,  5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),                 
  new tagLunarCal( 47,  0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),                 
  new tagLunarCal( 36,  0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),                 
  new tagLunarCal( 25,  5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 117 */                 
  new tagLunarCal( 43,  0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),                 
  new tagLunarCal( 32,  0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),                 
  new tagLunarCal( 22,  3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];                 
                 
                 
/* 公元年每月之日數 */                 
SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];                 
                 
/* 公元年每月之累積日數, 平年與閏年 */                 
SolarDays = [                 
  0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396,                 
  0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];                 
AnimalIdx = ["馬", "羊", "猴", "雞", "狗", "豬", "鼠", "牛", "虎", "兔", "龍", "蛇" ];                 
LocationIdx = [ "南", "東", "北", "西" ];                 
                 
if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return 1;                 
                 
sm = SolarMonth - 1;                 
                 
if ( sm < 0 || sm > 11 ) return 2;                 
                 
leap = GetLeap( SolarYear );                 
                 
if ( sm == 1 )                 
d = leap + 28;                 
else                 
d = SolarCal[sm];                 
                 
if ( SolarDate < 1 || SolarDate > d ) return 3;                 
                 
y = SolarYear - FIRSTYEAR;                 
acc = SolarDays[ leap*14 + sm ] + SolarDate;                 
kc = acc + LunarCal[y].BaseKanChih;                 
Kan = kc % 10;                 
Chih = kc % 12;                 
Location = LocationIdx[kc % 4];                 
Age = kc % 60;                 
if ( Age < 22 )                 
Age = 22 - Age;                 
else                 
Age = 82 - Age;                 
                 
Animal = AnimalIdx[ Chih ];                 
                 
if ( acc <= LunarCal[y].BaseDays ) {                 
y--;                 
LunarYear = SolarYear - 1;                 
leap = GetLeap( LunarYear );                 
sm += 12;                 
acc = SolarDays[leap*14 + sm] + SolarDate;                 
}                 
else                 
LunarYear = SolarYear;                 
                 
l1 = LunarCal[y].BaseDays;                 
for ( i=0; i<13; i++ ) {                 
l2 = l1 + LunarCal[y].MonthDays + 29;                 
if ( acc <= l2 ) break;                 
l1 = l2;                 
}                 
                 
LunarMonth = i + 1;                 
LunarDate = acc - l1;                 
im = LunarCal[y].Intercalation;                 
                 
if ( im != 0 && LunarMonth > im ) {                 
LunarMonth--;                 
if ( LunarMonth == im ) LunarMonth = -im;                 
}                 
                 
if ( LunarMonth > 12 ) LunarMonth -= 12;                 
today=new Date();                 
      function initArray(){                 
                 this.length=initArray.arguments.length                 
                 for(var i=0;i<this.length;i++)                 
                 this[i+1]=initArray.arguments  }                 
     var d=new initArray("<font size=&#39;2&#39; color=#CC0033><b>星期日</b></font>","<font size=&#39;2&#39; color=#CC0033><b>星期一</b></font>","<font size=&#39;2&#39; color=#CC0033><b>星期二</b></font>","<font size=&#39;2&#39; color=#CC0033><b>星期三</b></font>","<font size=&#39;2&#39; color=#CC0033><b>星期四</b></font>","<font size=&#39;2&#39; color=#CC0033><b>星期五</b></font>","<font size=&#39;2&#39; color=#CC0033><b>星期六</b></font>");                 
         document.write("<font size=&#39;2&#39; color=#3333CC><b>日曆:</b><font size=&#39;2&#39; size=&#39;2&#39; color=#CC0033><b>",today.getYear()-0000,"</b><font size=&#39;2&#39; color=#3333CC><b>年</b></font><b>",today.getMonth()+1,"</b><font size=&#39;2&#39; color=#3333CC><b>月</b></font><b>",today.getDate(),"</b><font size=&#39;2&#39; color=#3333CC><b>日</b></font>"                 
      ,d[today.getDay()+1],"");               
  document.write( "<font size=&#39;2&#39; color=#3333CC><span class=d><b>農曆:</b><font size=&#39;2&#39; color=#CC0033><b>" + LunarMonth + "</b><font size=&#39;2&#39; color=#3333CC><b>月</b></font><b>" + LunarDate + "</b><font size=&#39;2&#39; color=#3333CC><b>日</b></font></span></font>" );            
                 
     document.write( "<span class=d><font size=&#39;2&#39; color=#3333CC><b>煞</b></font><b><font size=&#39;2&#39; color=#CC0033>" + Location + " </font></b><font size=&#39;2&#39; color=#3333CC><b>沖</b></font><b><font size=&#39;2&#39; color=#CC0033>" + Animal +  "</font></b></span><br>" );                           
                           
                  
return 0;                 
}                 
                 
/* 求此公元年是否為閏年, 返回 0 為平年, 1 為閏年 */                 
function GetLeap( year )                 
{                 
  if ( year % 400 == 0 )                 
    return 1;                 
  else if ( year % 100 == 0 )                 
    return 0;                 
  else if ( year % 4 == 0 )                 
    return 1;                 
  else                 
    return 0;                 
}                 
                 
function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) {                 
this.BaseDays = d;      /* 到公元 1 月 1 日到農曆正月初一的累積日數 */                 
this.Intercalation = i;   /* 閏月月份. 0==此年沒有閏月 */                 
this.BaseWeekday = w;    /* 此年公元 1 月 1 日為星期幾再減 1 */                 
this.BaseKanChih = k;    /* 此年公元 1 月 1 日之干支序號減 1 */                 
this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此農曆年每月之大小, 0==小月(29日), 1==大月(30日) */                 
}                 
//-->                  
  </SCRIPT>
<SPAN id=liveclock 15px? height: 109px; style?="width:"></SPAN>
<SCRIPT language=javascript>
function www_helpor_net()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()

if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="<font size=&#39;2&#39; color=#3333CC><b>現在北京時間是</b><font size=&#39;2&#39; color=#CC0033><b>"+hours+":"+minutes+":"+seconds+"  </b></font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
CalConv();
//-->  </script>

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 顶 踩
2#
发表于 2006-12-16 23:51 | 只看该作者
说实话 `` 不知道
3#
发表于 2006-12-17 01:47 | 只看该作者
liveclock.innerHTML=myclock
这个会报错
我们应该用

try{
document.getElementById("liveclock").innerHTML=myclock;
}catch(e){}

这样就不会报错,也能正常显示了

不过你给出的这段代码是有问题的,有部分数据会取不出来

以下附上我修改后的代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
4#
发表于 2006-12-17 04:10 | 只看该作者
貌似是一个时间 什么的
5#
发表于 2006-12-17 17:07 | 只看该作者
引用第3楼海院の水水2006-12-17 04:10发表的“”:
貌似是一个时间 什么的

公历农历时间,和黄历有关,感觉

什么宜什么忌什么的
6#
发表于 2006-12-17 17:48 | 只看该作者
哪偷来的代码?还是繁体的!
7#
发表于 2006-12-17 20:08 | 只看该作者
呵呵,LZ在学JAVA勒,
8#
发表于 2006-12-17 20:52 | 只看该作者
介个是javascript,和java两回事
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋| 碧海潮声大学生网  

Copyright © 2001-2013 Comsenz Inc.   All Rights Reserved.

Powered by Discuz! X3.2( 浙ICP备11026473号 )

快速回复 返回顶部 返回列表