可以根据用户的IP直接显示当地3天内的天气情况,纯静态非常小巧,可以直接插入任何网页.
下载: http://bbs.chinaz.com/UploadFile/2005-8/200581113211254275.rar
其实就是一段代码,保存为HTML文件weather.htm即可。
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>天气预报</title> <style type="text/css"> <!-- { margin: 0px; } .f14b { font-size: 12px; font-weight: bold; color: #333333; } .f12orange { font-size: 12px; color: #ff6600; } .f2blue { font-size: 12px; color: #333333; } .f12blue2 { font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #0066cc; } .f12red { font-size: 12px; color: #ff6600; font-family: Arial, Helvetica, sans-serif; } .f2black { font-size: 12px; color: #000000; } --> </style> <script language="JavaScript" type="text/JavaScript"> <!-- var openW;
function openWindow(theURL,winName,features) { //v2.0 //openW=window.open(theURL,winName,features); //var mxh2 = window.open("about:blank","window_mxh") //var mxh2 =window.open(theURL,winName,features); window.showModalDialog(theURL,test(),'dialogHeight:270px;dialogWidth:265px;scroll:no;status:no') } function test(){ location.href="index.htm";
} //--> </script>
<script language="javascript" id="objscript"></script> <script language="JavaScript" type="text/JavaScript" src="http://www.116.com.cn/116/home/weather/public.js"></script> <script language="JavaScript" type="text/JavaScript" src="http://www.116.com.cn/116/home/weather/weather.js"></script> <script language="JavaScript" type="text/JavaScript" src="http://jsp.116.com.cn/notice/iptocityid.jsp"></script> <script language="JavaScript">
var locid; var cityname; var defid; if(getCookie("defid")=='') { locid=CityID; setCookie("defid",CityID); }else { locid=getCookie("defid"); } var havecheck; if(getCookie("check")==''){ havecheck='2'; }else{ havecheck=getCookie("check"); } var show; if(havecheck=='0'){ locid=getCookie("CityID"); show=0; }else { locid=getCookie("defid"); show=1; } var urlstr = "http://jsp.116.com.cn/weather/"+locid+".js"; document.all["objscript"].src = urlstr; //var oWea = new makeWeatherObj(); </script>
<body topmargin="0" leftmargin="0"> <SCRIPT language="javascript"> var oWea = new makeWeatherObj(); </script> <div align="center"> <table width="195" height="85" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="195" valign="bottom" class="f14b"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="10"></td> </tr> <tr> <td align="center" class="f14b">您所在的城市:<font color="#ff6600"> <SCRIPT language="javascript"> document.write(oWea.swName); </script></font> </td> </tr> <tr> <td height="10"></td> </tr> </table></td> </tr> <tr> <form name="form1" method="post" action=""> <td width="160" align="center" valign="top"> <table width="190" border="0" cellspacing="0" cellpadding="0"> <tr align="center" valign="bottom"> <td width="60" height="15" class="f12orange">今天</td> <td width="60" class="f2blue">明天</td> <td width="60" class="f2blue">后天</td> </tr> <tr> <td height="10"></td> </tr> <tr align="center"> <td height="25"><SCRIPT language="javascript"> var weather24=oWea.swWeather24.split("-"); document.write("<img src=http://www.116.com.cn/116/home/weather/images/icons/"+transTab(weather24[0])+"_small.gif border='0'>"); if(weather24.length==2) document.write("<img src=http://www.116.com.cn/116/home/weather/images/icons/"+transTab(weather24[1])+"_small.gif border='0'>"); </script></td> <td><SCRIPT language="javascript"> var weather48=oWea.swWeather48.split("-"); document.write("<img src=http://www.116.com.cn/116/home/weather/images/icons/"+transTab(weather48[0])+"_small.gif border='0'>"); if(weather48.length==2) document.write("<img src=http://www.116.com.cn/116/home/weather/images/icons/"+transTab(weather48[1])+"_small.gif border='0'>"); </script></td> <td><SCRIPT language="javascript"> var weather72=oWea.swWeather72.split("-"); document.write("<img src=http://www.116.com.cn/116/home/weather/images/icons/"+transTab(weather72[0])+"_small.gif border='0'>"); if(weather72.length==2) document.write("<img src=http://www.116.com.cn/116/home/weather/images/icons/"+transTab(weather72[1])+"_small.gif border='0'>"); </script></td> </tr> <tr align="center"> <td><SCRIPT language="javascript"> var wendu=oWea.swWendu24.split("-"); document.write("<span class='f12blue2'>"+wendu[0]+"</span>"); </script></td> <td height="20"><SCRIPT language="javascript"> var wendu=oWea.swWendu48.split("-"); document.write("<span class='f12blue2'>"+wendu[0]+"</span>"); </script></td> <td height="20"><SCRIPT language="javascript"> var wendu=oWea.swWendu72.split("-"); document.write("<span class='f12blue2'>"+wendu[0]+"</span>"); </script> </td> </tr> </table></td> </form> </tr> </table></div>
页面调用代码: <iframe frameborder=0 width=160 height=100 marginheight=0 marginwidth=0 name=weather scrolling=no title="天气预报" src="/weather.htm"></iframe> |