您好,欢迎来到榕意旅游网。
搜索
您的当前位置:首页html中嵌入天气预报_html/css

html中嵌入天气预报_html/css

来源:榕意旅游网
先看效果:

html代码:

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 = "";
        var day = (new Date().getMonth()+1)+"月"+(new Date().getDate())+"日";
        var tq = ""+"

"+""+day+""+_w.s1+"

"+"

"+_w.t1 + "℃~" + _w.t2 + "℃"+"

"+""+img;
        $('#weather').html(tq);
      }
    });
  });
}
findWeather();

Copyright © 2019- nryq.cn 版权所有 赣ICP备2024042798号-6

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务