87,991
社区成员
发帖
与我相关
我的任务
分享
<script src="Scripts/jquery-1.4.1.js"></script>
<script src="Scripts/jqPagination/js/WeatherConv.js"></script>
<script type="text/javascript" src="http://counter.sina.com.cn/ip"></script>
<script type="text/javascript">
//创建天气预报核心对象
$(document).ready(function () {
url = "http://api.worldweatheronline.com/free/v1/weather.ashx?q=" + ILData[0] + "&format=json&num_of_days=1&key=yourkey&callback=?";
$.getJSON(url, function (result) {
var strdate = new Date(result.data.weather[0].date);
$("#date").html(strdate.toLocaleDateString());
$("#tempMinC").html(result.data.weather[0].tempMinC);
$("#tempMaxC").html(result.data.weather[0].tempMaxC);
var type = result.data.weather[0].weatherCode;
if (WeatherType[type] != null) {
$("#weatherDesc").html(WeatherType[type]);
}
else {
$("#weatherDesc").html(result.data.weather[0].weatherDesc[0].value);
}
var wind = result.data.weather[0].winddir16Point;
if (Windcompass[wind] != null) {
$("#Wind").html(Windcompass[wind]);
}
$("#weatherIconUrl").attr('src', result.data.weather[0].weatherIconUrl[0].value);
});
});
</script><div>
<div style="float: left;">
<img id="weatherIconUrl" alt="" src="" />
</div>
<div style="float: left;margin-left:2px;">
<div id="temp"><span id="tempMinC"></span>C~<span id="tempMaxC"></span>C</div>
<div id="weatherDesc"></div>
<div id="Wind"></div>
<div id="date"></div>
</div>
</div>
感谢分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>weather.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.4.1.js"></script>
<script type="text/javascript" src="WeatherConv.js"></script>
<script type="text/javascript" src="http://counter.sina.com.cn/ip"></script>
<script type="text/javascript">
//创建天气预报核心对象
$(document).ready(function () {
url = "http://api.worldweatheronline.com/free/v1/weather.ashx?q=" + ILData[0] + "&format=json&num_of_days=1&key=yourkey&callback=?";
$.getJSON(url, function (result) {
var strdate = new Date(result.data.weather[0].date);
$("#date").html(strdate.toLocaleDateString());
$("#tempMinC").html(result.data.weather[0].tempMinC);
$("#tempMaxC").html(result.data.weather[0].tempMaxC);
var type = result.data.weather[0].weatherCode;
if (WeatherType[type] != null) {
$("#weatherDesc").html(WeatherType[type]);
}
else {
$("#weatherDesc").html(result.data.weather[0].weatherDesc[0].value);
}
var wind = result.data.weather[0].winddir16Point;
if (Windcompass[wind] != null) {
$("#Wind").html(Windcompass[wind]);
}
$("#weatherIconUrl").attr('src', result.data.weather[0].weatherIconUrl[0].value);
});
});
</script>
</head>
<body>
<div>
<div style="float: left;">
<img id="weatherIconUrl" alt="" src="" />
</div>
<div style="float: left;margin-left:2px;">
<div id="temp"><span id="tempMinC"></span>C~<span id="tempMaxC"></span>C</div>
<div id="weatherDesc"></div>
<div id="Wind"></div>
<div id="date"></div>
</div>
</div>
</body>
</html>



