---
title: "知识可以触类旁通。。。"
author: "mmdev"
date: "2007-12-31T18:37:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2007-12-31T18:37:00Z"
id: 990268
url: "https://mmdev.iteye.com/blog/990268"
---

这次元旦放假，休息了一下身心。版里首页需要一个万年历，我打算将它做成可以显示版友生日的万年历。当然，改代码是毋庸置疑的了。还好，以前在大学的时候曾经学过网页制作，对HTML语言也比较了解。当年，Dreamweaver还不流行的时候，我就是用记事本来写HTML语言的。但是，对Javascript就不了解了，那时候学的是VBScript。这些都靠自学。

为了实现这个功能，硬着头皮去看满篇的Javascript。每个函数每个函数的去研究。google的用途就派上了，JavaScript语法，脚本等等。都是从google上得来。仿照写了几个函数，都没有实现得了，差点半途放弃。不过，后来还是耐心的去学，去看，去模仿。连续两天，一直搞到凌晨1点半，貌似大学的劲头来了。记得当年在学校的时候，没有电脑，为了做网页，到网吧通宵。

功夫不负有心人。研究了两天之后，终于模仿写了一个函数，实现了我要的功能。当然，在行内人士来说，不值一提。可是对我这个没有基础的人来说，几个小时的啃代码，然后能实现我要的功能，也算是小兴奋了一下。

有个疑点：网页制作有没有类似单步调试的东东。要不这调试也太费劲了。看不到变量，看不到执行步骤，只能花时间去试。现在的网页制作技术也不知道发展到何种水平了。

技术是相通的。无论是嵌入式技术，还是网页技术。他们的精髓，思想还是一致的。只是可能概念不同，侧重点不同而已。

以下是部分万年历代码：

function showbirth() {  
var sD,s,size;  
cld = new calendar(tY,tM);  
{

sObj=eval('BID');

sObj.className = '';

sD = tD-1;

if(sD&gt;-1 && sD&lt;cld.length) { //日期内  
//sObj.innerHTML = sD+1;

if(cld\[sD].isToday) sObj.className = 'blue'; //今日颜色

sObj.style.color = cld\[sD].color; //国定假日颜色

s=cld\[sD].lunarFestival;  
if(s.length&gt;0) { //农历节日  
if(s.length&gt;6) s = s;  
s = s.fontcolor('red');  
}  
else { //国历节日  
s=cld\[sD].solarFestival;  
if(s.length&gt;0) {  
size = (s.charCodeAt(0)&gt;0 && s.charCodeAt(0)&lt;128)?8:4;  
if(s.length&gt;size+2) s = s;  
s = s.fontcolor('red');  
}  
else { //廿四节气  
s=cld\[sD].solarTerms;  
if(s.length&gt;0) s = s.fontcolor('red');  
}  
}  
if(s.length&gt;0)  
{  
s='今天是&lt;B&gt;'+s+'&lt;/b&gt;';  
sObj.innerHTML = s;  
}

}  
else { //非日期  
sObj.innerHTML = '';  
}  
}  
}

只需在初始化函数里加入这个函数。

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)functioninitial()...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)dStyle=detail.style;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)CLD.SY.selectedIndex=tY-1900;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)CLD.SM.selectedIndex=tM;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)drawCld(tY,tM);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)showbirth();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)CLD.TZ.selectedIndex=getCookie("TZ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)changeTZ();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)tick();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

然后在表格中加入&lt;FONT id="BID"color=#ff6633 size=3&gt; &lt;/FONT&gt;，就能将生日显示在这个里面了。

有趣~~~~~~~~~~~~~

不过还请行家留点口德。。。。。。