- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>无标题文档</title>
- <script src="http://libs.baidu.com/jquery/1.7.0/jquery.min.js"></script>
- <script language="JavaScript" type="text/javascript">
- 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 class='lazy' style='display: block;' src='http://i2.sinaimg.cn/dy/main/weather/weatherplugin/wthIco/20_20/" +_f
- + "' />";
-
- var tq = img + "<span>" + _w.s1 + " " + _w.t1 + "℃~" + _w.t2 + "℃ </span><span>风力等级:<em>" + _w.p1 + "</em></span>";
-
-
- $('#weather').html(tq);
- }
- });
- });
- </script>
- <style type="text/css">
- .weather{ border-top:1px solid #ddd; margin-bottom:0px; position:relative; width:250px;}
- .weather div{height:65px;}
- .weather i{
- width:80px;
- height:65px;
- text-indent:-99999px;
- float:left;
- background-position:0 -80px;
- background-repeat: no-repeat;
- background-image: url(indexpress.png);
- }
- .weather p{float:right; display:inline; width:120px; position:absolute; zoom:1; padding:0px 0 0 45px; top:0; right:0; z-index:99;}
- .weather p img{ position:absolute; left:0; width:40px; height:40px; vertical-align:bottom; background:none;}
- .weather p span{ color:#666; display:block; line-height:20px; height:20px; overflow:hidden; white-space:nowrap;}
- .weather p span em{ background-color:#54a932; padding:1px 2px; color:#fff;}
- .weather ul{ background-color:#f6f6f6; padding:3px 10px; margin-top:5px;}
- .weather li{ line-height:24px; height:24px; overflow:hidden; padding-left:12px; background-position:-240px -144px;}
- .weather li a{ color:#333;}
- body,td,th {
- font-size: 12px;
- }
- </style>
- </head>
- <body>
- <div class="weather">
- <i>每日提醒</i>
- <p id="weather"></p>
-
- </div>
- </body>
- </html>
复制代码
以上是调用JQ来实现,怎么把脚本部份用核心JS实现。
|