日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

html中嵌入天气预报

發布時間:2025/7/25 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html中嵌入天气预报 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

先看效果:

html代碼:

<div id="weather"></div>

js代碼:

function findWeather() {
  var cityUrl = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js';
  $.getScript(cityUrl, function(script, textStatus, jqXHR) {
    var citytq = remote_ip_info.city ;// 獲取城市
    var url = "http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&city=" + citytq + "&day=0&dfc=3";
    $.ajax({
      url : url,
      dataType : "script",
      scriptCharset : "gbk",
      success : function(data) {
        var _w = window.SWther.w[citytq][0];

        var _f= _w.f1+"_0.png";
        if(new Date().getHours() > 17){
          _f= _w.f2+"_1.png";
        }
        var img = "<img width='40px' height='40px' style=' margin-left:20px'src='http://php.weather.sina.com.cn/images/yb3/78_78/" +_f+ "' />";
        var day = (new Date().getMonth()+1)+"月"+(new Date().getDate())+"日";
        var tq = "<div style='float:left'>"+"<p>"+"<span>"+day+"</span>"+_w.s1+"</p>"+"<p>"+_w.t1 + "℃~" + _w.t2 + "℃"+"</p>"+"</div>"+img;
        $('#weather').html(tq);
      }
    });
  });
}
findWeather();

轉載于:https://www.cnblogs.com/chenrunlin/p/4935172.html

總結

以上是生活随笔為你收集整理的html中嵌入天气预报的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。