html网页调用天气预报的几种方法

html-css08

html网页调用天气预报的几种方法,第1张

1、QQ天气

<IFRAME ID='ifm2' WIDTH='189' HEIGHT='190' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC='></IFRAME>

优缺点:界面不错,可以自己设置一个默认城市,其他城市可以在下面选择,方便快捷。缺点就是你也知道默认城市的代码,可以看这里(有一些也不准)。

2、QQ天气

<iframe width=160 height=230 frameborder=0 scrolling=NO src=appnews.qq.com/cgi-

bin/news_qq_search?city=重庆></iframe>

<iframe src=" http://m.weather.com.cn/n/pn14/weather.htm" width="260" height="30" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>天气代码 //日期代码<script language="JavaScript">

function number(index1){

var numberstring="一二三四五六七八九十"

if(index1 ==0) {document.write("十")}

if(index1 <10){

document.write(numberstring.substring(0+(index1-1),index1))}

else if(index1 <20 ){

document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}

else if(index1 <30 ){

document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}

else{

document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}

}var today1 = new Date()

var month = today1.getMonth()+1

var date = today1.getDate()

var day = today1.getDay()

number(month)

document.write("月")

number(date)

document.write("日")

</script>