本帖最后由 owenwudi2 于 2010-01-06 15:54 编辑
今天给大家分享下直接调用一行文字的天气预报代码
(滚动)日期+农历+天气预报代码给大家分享放在首页index.html.php文件里可直接调用
演示地址www.ccrmw.com左上
另外请教高手解决我的天气预报代码不持续循环问题 (方法正确2金币报酬)
请高手帮我写几个规则 体育 股票 基金 银行 旅游 星座 彩票 亲子 采集规则 (3金币一个)
能帮忙的高手直接回复我 谢谢
注意:天气预报代码要放在模板的index.html.php文件里
以下是展示代码:-
- 今天是:<td align="center"><span id="disp1"></span></td>
- <td align="left"><span id="disp3"></span></td>
- <td align="left"><span id="disp2"></span></td>
- <td align="left">农历<span id="disp4"></span></td>
- </tr>
- </table>
- <script>
- function getlastmonthday(y,m)
- {
- m=m-1;
- if(m==0) m=12;
- if(m==2)
- {
- if(isleapyear(y)==1)
- day=29;
- else
- day=28;
- }
- else if(m==1||m==3||m==5||m==7||m==8|m==10|m==12)
- day=31;
- else
- day=30;
- return(day);
- }
- function getmonthday(y,m)
- {
- if(m==2)
- {
- if(isleapyear(y)==1)
- day=29;
- else
- day=28;
- }
- else if(m==1||m==3||m==5||m==7||m==8|m==10|m==12)
- day=31;
- else
- day=30;
- return(day);
- }
- function isleapyear(n)
- {
- if( (n%4==0&&n%100!=0) || n%400==0 )
- return(1);
- else
- return(0);
- }
- function getyeardays(y)
- {
- if(isleapyear(y)==1)
- return(366);
- else
- return(365);
- }
- function getpassdays(y1,m1,d1,y2,m2,d2)
- {
- y=y2-y1;
- n=0;
- if(y>=1)
- {
- for(k=y1+1;k<=y2-1;k++)
- {
- n=n+getyeardays(k);
- }
- n=n+getpassdays2(y1,m1,d1,12,31);
- n=n+getpassdays2(y2,1,1,m2,d2)+1;
- }
- if(y==0)
- {
- n=n+getpassdays2(y1,m1,d1,m2,d2);
- }
- return(n);
- }
- function getpassdays2(y1,m1,d1,m2,d2)
- {
- m=m2-m1;
- n=0;
- if(m>=1)
- {
- for(i=m1+1;i<=m2-1;i++)
- {
- n=n+getmonthday(y1,i);
- }
- n=n+getmonthday(y1,m1)-d1;
- n=n+d2;
- }
- if(m==0)
- {
- n=n+d2-d1;
- }
- return(n);
- }
- function getxqstr(xq)
- {
- switch(xq)
- {
- case 0:xqstr="星期日";break;
- case 1:xqstr="星期一";break;
- case 2:xqstr="星期二";break;
- case 3:xqstr="星期三";break;
- case 4:xqstr="星期四";break;
- case 5:xqstr="星期五";break;
- case 6:xqstr="星期六";break;
- }
- return(xqstr);
- }
- var t1=new Date<!-- #BeginDate format:fCh2m -->('Jan 19,2008 23:45:19')<!-- #EndDate -->;
- var year1 = t1.getYear();
- if(year1<1900) year1=1900+year1;
- var month1 = t1.getMonth()+1;
- var day1 = t1.getDate();
- var xq1 = t1.getDay();
- var hh1 = t1.getHours();
- var mm1 = t1.getMinutes();
- var ss1 = t1.getSeconds();
- var t2 = new Date();
- var ss2 = t2.getSeconds();
- ssc=ss1-ss2;
- var year2 = year1;
- var month2 = month1;
- var day2 = day1;
- var xq2 = xq1;
- var hh2 = hh1;
- var mm2 = mm1;
- var ss2old;
- var year3,month3,day3; //定义为全局变量
- var hh3,mm3;
- var isdispnl=0;
- function disptime_axpj()
- {
- var t2 = new Date();
- var ss2 = t2.getSeconds();
- if(ss2-ss2old>2||ss2-ss2old<-2)
- ss2=ss2old+1;
- if(ss2==0)
- { mm2=mm2+1; }
- else if(ss2>=60)
- { mm2=mm2+1; ss2=ss2-60; }
- if(mm2>=60) { hh2=hh2+1; mm2=mm2-60; }
- if(hh2>=24) { day2=day2+1; xq2=xq2+1; hh2=hh2-24; }
- if(xq2>=7) { xq2=xq2-7; }
- dd=getmonthday(year2,month2);
- if(day2>dd)
- { month2=month2+1; if(month2==13) { month2=1; year2=year2+1; }
- day2=day2-dd;
- }
- if(month2>=13) { year2=year2+1; month2=month2-12 ; }
- year3 = year2;
- month3 = month2;
- day3 = day2;
- var xq3 = xq2;
- hh3 = hh2;
- mm3 = mm2;
- var ss3 = ss2+ssc;
- if(ss3<0) { mm3=mm3-1; ss3=ss3+60; }
- if(ss3>=60) { mm3=mm3+1; ss3=ss3-60; }
- if(mm3<0) { hh3=hh3-1; mm3=mm3+60; }
- if(mm3>=60) { hh3=hh3+1; mm3=mm3-60; }
- if(hh3<0) { day3=day3-1; hh3=hh3+24; }
- if(hh3>=24) { day3=day3+1; hh3=hh3-24; }
- if(xq3<0) { xq3=xq3+7; }
- if(xq3>=7) { xq3=xq3-7; }
- if(day3<=0)
- {
- dd=getlastmonthday(year3,month3);
- month3=month3-1; if(month3==0) { month3=12; year3=year3-1; }
- day3=day3+dd;
- }
- dd=getmonthday(year3,month3);
- if(day3>dd)
- { month3=month3+1; if(month3==13) { month3=1; year3=year3+1; }
- day3=day3-dd;
- }
- if(month3<=0) { year3=year3-1; month3=month3+12; }
- if(month3>=13) { year3=year3+1; month3=month3-12; }
- if(mm3<=9) mm3="0"+mm3;
- if(ss3<=9) ss3="0"+ss3;
- document.getElementById("disp1").innerHTML=""+year3+"年"+month3+"月"+day3+"日";
- document.getElementById("disp2").innerHTML=""+hh3+":"+mm3;
- document.getElementById("disp3").innerHTML=""+getxqstr(xq2);
- dispnl();
- ss2old=ss2;
- window.setTimeout("disptime_axpj()", 1000);
- }
- function dispnl()
- {
- isdispnl=1;
- var ny=new Array(0,29,29,30,29,29,30,29,30,30,30,29,30 , 30,29,29,30,29,29,30,29,30,30,29,30 , 30,30,29,29,30 ,29,29,30,29,30,29,30,30);
- var nlyearname=new Array("0","丁亥年","戊子年","己丑年");
- var dxnum=new Array("0","一","二","三","四","五","六","七","八","九","十","十一","十二");
- n=getpassdays(2007,2,18,year3,month3,day3);
- i=1;
- nlmonth=1;
- nlyearno=1;
- while(n-ny[i]>=0)
- {
- n=n-ny[i];
- nlmonth=nlmonth+1;
- if(nlmonth==13)
- { nlmonth=1; nlyearno=nlyearno+1; }
- i=i+1;
- }
- nyn=nlyearname[nlyearno];
- if(i>=30) nlmonth=nlmonth-1;
- nlday=n+1;
- nlmonth2=""+dxnum[nlmonth]+"月";
- if(nlday<=10)
- nlday2="初"+dxnum[nlday];
- else if(nlday>=11&&nlday<=19)
- nlday2="十"+dxnum[nlday-10];
- else if(nlday==20)
- nlday2="廿十";
- else if(nlday>=21&&nlday<=29)
- nlday2="廿"+dxnum[nlday-20];
- else if(nlday==30)
- nlday2="三十";
- else
- nlday2="";
- document.getElementById("disp4").innerHTML=""+nyn+" "+nlmonth2+nlday2;
- }
- function dispxl()
- {
- isdispnl=0;
- document.getElementById("disp1").innerHTML=""+month3+"月"+day3+"日";
- document.getElementById("disp2").innerHTML=""+hh3+":"+mm3;
- document.getElementById("disp3").innerHTML=""+getxqstr(xq2);
- }
- disptime_axpj();
- </script><iframe src="http://m.weather.com.cn/m/p2/weather1.htm" width="220" height="14" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="No"></iframe>本站已安全运行了:</font></b><font color="#FF0000" size="2" face="隶书"><b> </b>
- <strong><script language="JavaScript">
- function DateDiff(sDate1, sDate2)
- {
- var aDate, oDate1, oDate2, iDays
- aDate = sDate1.split("-")
- oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
- aDate = sDate2.split("-")
- oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
- iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24)
- return iDays
- }
- s1 ="2010-01-1"
- var now=new Date();
- var year=now.getYear();
- var month=now.getMonth()+1;
- var day=now.getDate();
- s2=year+"-"+month+"-"+day;
- document.write(DateDiff(s1,s2));
- </script></strong></font><b><font color="#FF0000" size="2" face="新宋体">天</font></b></td></span>
复制代码 |