JS 获取新浪天气接口的实现代码
<! Doctype html> <html> <fead> <meta charset = "utf-8"> <meta http-oquiv = "x-ua compatible" content = "ie = bord"> <title> 天气 </title> </head> <body> <div> <span id = "sj"> </span Id = "weather"> <img src <form de acción = "/búsqueda" método = "get" id = "qform" style = "text-align: right; visual target = "_ en blanco"> <span> <input name = "Keywords" id = "q" tabindex = "1" valor = "" maxLength = "100" Autocomplette = "Off"> </span> <span> <input type = "envíalo" Tabindex = "2" ID = "Su" Value = "搜索" estilo = "Padding: 0px 5px; type = "text/javaScript" src = "jQuery-1.8.3.min.js"> </script> <script type = "text/javaScript"> function showLocale (objd) {var str, colorhead, colorfoot; var yy = objd.getyear (); if (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 = ""; if (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; regreso (str); } function tick () {var hoy; hoy = nueva fecha (); document.getElementById ("SJ"). InnerHtml = showLocale (Today); Window.setTimeout ("tick ()", 1000); } garrapata(); function findweather () {var cityUrl = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js'; $ .getScript (CityUrl, function (script, textStatus, jqxhr) {var citytq = remoto_ip_info.city; // 获取城市 citytq = "郑州"; var url = "http://php.weather.sina.com.cn/iframe/w_cl.php?code=js&city=" + " +" + " +" + Citytq + " "& day = 0 & dfc = 3"; _W.F2 + "_1.png"; + " + _W.S1 +" " + _W.T1 +" ℃~ " + _W.T2 +" ℃ " + _W.D1 + _W.P1 +" 级 " } findweather () </script> </body> </html>以上这篇 JS 获取新浪天气接口的实现代码就是小编分享给大家的全部内容了 , 希望能给大家一个参考 也希望大家多多支持武林网。