JS获取新浪天气接口的实现代码
<!doctype html> <html> <head> <meta charset =“ utf-8”> <meta http-equiv =“ x-ua-相处action =“/search” method =“ get” id =“ q form” style =“ text-align:right; display:inline; float; float:right; padding-right:10px;'' target =“ _ blank”> <span> <input name =“关键字” id =“ q” type =“ text/javascript” src =“ jquery-1.8.3.3.min.js”> </script> <script> <script type =“ text/javascript”>函数showlocale(objd){var str,colorhead,colorhead,colorfoot; var yy = objd.getyear();如果(yy <1900)yy = yy + 1900; var mm = objd.getMonth() + 1; if(mm <10)mm ='0' + mm; var dd = objd.getDate(); if(dd <10)dd ='0' + dd; var hh = objd.gethours(); if(hh <10)hh ='0' + hh; var mm = objd.getminutes(); if(mm <10)mm ='0' + mm; var ss = objd.getSeconds(); if(ss <10)ss ='0' + ss; var ww = objd.getDay(); if(ww == 0)colorhead =“”;如果(ww> 0 && ww <6)colorhead =“”; if(ww == 6)colorhead =“”; if(ww == 0)ww =“星期日”; if(ww == 1)ww =“星期一”; if(ww == 2)ww =“星期二”; if(ww == 3)ww =“星期三”; if(ww == 4)ww =“星期四”; if(ww == 5)ww =“星期五”; if(ww == 6)ww =“星期六”; colorfoot =“” str = colorhead + yy +“ - ” + mm +“ - ” + dd +“” + hh +“:” + mm +“:” + ss +“” + ww + colorfoot;返回(str); }函数tick(){var today;今天= new Date(); document.getElementById(“ sj”)。innerhtml = showlocale(today); window.setTimeout(“ tick()”,1000); } 打钩();功能FindWeather(){var cityurl ='http://int.dpool.sina.com.cn/iplookup/iplookup/iplookup.php?format=js'; $ .getScript(cityUrl,函数(脚本,textStatus,jqxhr){var citytq = remote_ip_info.city; //获取城市citytq =“郑州”; var url =“ http://php.weather.sina.com.c.com.cn/iframe/iframe/index/index/index/index/index/index/index/index/index/index/index/cl.cl.php? “&Day = 0&dfc = 3”; _w.f2 +“ _1.png”;} var img =“ <img width ='16px'高度='16px'src ='http://i2.sinaimg.cn/main/main/main/main/main/weather/weather/weather/weather/weather/weather/weather/weatherplugin/weatherplugin/weatherplugin/wthico/20_20/20_20/ +“” + _W.S1 +“” + _W.T1 +“ ℃~” + _W.T2 +“℃” + _W.D1 + _W.P1 +“ $ $('#weather”)。 } Findweather()</script> </body> </html>以上这篇js获取新浪天气接口的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。,也希望大家多多支持武林网。