JS 获取新浪天气接口的实现代码
<! docType html> <html> <head> <meta charset = "utf-8"> <meta http-equiv = "x-ua-catsible"content = "ie get"> <title> </title> </head> <body> <sj "> </span> <span id ="> </head> <body> <sj "> <" ""> <form action = "/search"method = "get"id = "qform"style = "text-align : right; display : inline; float; 오른쪽; 패딩-오른쪽 : 10px;" 대상 = "_ blank"> <span> <입력 이름 = "키워드"id = "q"tabindex = "1"value = ""maxlength = "100"autocomplete = "off"> </span> <span> <입력 유형 = "tabindex ="id = "su"value = "搜索"style = "padding : 0px 5px; type = "text/javaScript"src = "jQuery-1.8.3.3.min.js"> </script> <script type = "text/javaScript"> 함수 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; 반환 (str); } function tick () {var 오늘; 오늘 = 새로운 날짜 (); document.getElementById ( "sj"). innerHtml = showlocale (오늘); Window.settimeout ( "tick ()", 1000); } tick (); 함수 findweather () {var cityurl = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js'; $ .getScript (CityUrl, function (스크립트, TextStatus, jqxhr) {var citytq = remote_ip_info.city; // 获取城市 citytq = "郑州"; var url = "http://php.weather.sina.com.cn/iframe/index/w_cl.php?city=JS=" + citytq + "& day = 0 & dfc = 3"; $ .ajax ({url : url, datatype : "script", scriptcharset : "gbk", success (data) {var _w = wind = _w.f2 + "_1.png"; img + " + _w.s1 +" + _w.t1 + " + _w.t2 +" + _w.d1 + _w.p1 + "$ ( '#weather'); } findweather () </script> </body> </html>以上这篇 js 获取新浪天气接口的实现代码就是小编分享给大家的全部内容了 获取新浪天气接口的实现代码就是小编分享给大家的全部内容了, 希望能给大家一个参考, 也希望大家多多支持武林网。