方案一:
<!DOCTYPE html>
<html>
<head>
<title>调用天气预报接口</title>
</head>
<script type="text/javascript">
document.writeln("<iframe name=\"weather_inc\" src=\"http:\/\/i.tianqi.com\/index.php?c=code&id=1\" width=\"330\" height=\"35\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>");
</script>
<body>
<!-- 天气预报接口 -->
<iframe width="420" scrolling="no" height="60" frameborder="0" allowtransparency="true" src="http://i.tianqi.com/index.php?c=code&id=17&icon=1&num=3"></iframe>
<div class="weatherReport">
<iframe width="350" height="40" frameborder="0" scrolling="no" hspace="0" src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"></iframe>
</div>
另外,还有一些网站提供了免费的接口调用,很方便,可自定义天气预报样式并生成相应的代码,放在项目中即可直接使用
http://www.tianqi.com/plugin/
http://www.cnblogs.com/wangjingblogs/p/3192953.html
更多专业前端知识,请上 【猿2048】www.mk2048.com