如何用js调用天气预报代码 最新

JavaScript010

如何用js调用天气预报代码 最新,第1张

直接使用插件,如

<iframe width="214" scrolling="no" height="54" frameborder="0" allowtransparency="true" src="http://i.tianqi.com/index.php?c=code&id=42&icon=1&num=3"></iframe>

效果如下

这个插件来源是http://www.tianqi.com/plugin/

中国天气网的有点问题,可以用下面api,你直接放浏览器里打开就会显示结果

http://api.tocus.com.cn/weather2.php?send=北京

显示结果为

{"city":"北京","weather":"晴~阴","temp1":"26℃","temp2":"11℃"}

你可以参考下,天气api接口

http://www.tocus.com.cn/?send=article_show&id=105&class=2