分享

JS获取新浪天气

 likeju 2013-12-30

JS获取新浪天气

在要获取新浪天气的面页加入以下代码:

<script src="http://code./jquery-1.8.3.min.js" type="text/javascript"></script>

<script src="tianqi.js" type="text/javascript"></script>

<div id="tianqi"></div> //显示天气

以下为tianqi.js代码:

var weather=function(){

   var tmp=0;

   var SWther={w:[{}],add:{}};

   var SWther={};

   this.getWeather=function(type){

       $.getScript("http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&city="+citytq+"&day=0&dfc=3",function(){if(type=='js'){echo();}})

       ;}

function echo(){

   $('.tianqi').html(citytq+"温度:"+window.SWther.w[citytq][0].t1+"℃~"+window.SWther.w[citytq][0].t2+"℃  天气:"+window.SWther.w[citytq][0].s1+"~"+window.SWther.w[citytq][0].s2);

}

}

function jintian(){

   weather_.getWeather('js');

};

var weather_=new weather();

$(document).ready(function(){

$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){

   citytq=remote_ip_info.city //获取城市

       jintian();

})

}); 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多