很久以前做了一个天气预报的网站,放在哪里一直都没有管,不过最近突然流量大增,似乎被百度看上了,于是就把网站整理了一下,同时把之前本站的天气预报调用代码也重写了一次,这次写的调用代码比现在常见的一些调用代码要简洁和可控性得多,所有的代码都能自定义,不用iframe,用js加模板实现。
演示地址:http://www.sxxsw.com (在页面的右上方)
实例代码: 复制内容到剪贴板
代码:
<style>
#MZ_weather { width:160px; vertical-align:middle; text-align:left;}
#MZ_weather a { line-height:21px; text-decoration:none; color:#000;}
</style>
<div id="MZ_weather" style="display:none;">
<!-- 模板开始 -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right"><a title="点击查看更多信息" href="{url}" target="_blank" id="link">{city}<img src="/weather/images/{pic1}" width="35" height="21" /> {temperature1}</a></td>
</tr>
</table>
<!-- 模板结束 -->
</div>
<script>var cityId = 70000;</script>
<script src="/weather/load.js" language="javascript"></script>标签详解:
{url}:详细天气预报查看地
{city}:当前显示城市
{txt1}:天气类型(今天)
{pic1}:天气图标(今天)
{temperature1}:气温变化(今天)
{wind1}:风向风力情况(今天)
{txt2}:天气类型(明天)
{pic2}:天气图标(明天)
{temperature2}:气温变化(明天)
{wind2}:风向风力情况
{txt3}:天气类型(后天)
{pic3}:天气图标(后天)
{temperature3}:气温变化(后天)
{wind3}:风向风力情况(后天)
复制内容到剪贴板
代码:
<script>var cityId = 70000;</script>
<script src="/weather/load.js" language="javascript"></script> 上面代码中的“cityId”为指定的城市编号,如“70000”对应“长丰”,如果设置为“0”,即为更加用户IP自动显示所在地天气情况。
程序下载:
下载地址:
http://www.mzoe.com/downfile/weather.rar (文件更新时间:2008-8-21 23:31)
安装说明:将解压的文件上传至服务器更目录下的“weather”文件夹即可。
更加详细的介绍:
http://www.mzoe.com/demo/weather/
[
本帖最后由 mzoe 于 2008-9-24 00:02 编辑 ]