首页 > 代码库 > js根据IP取得天气

js根据IP取得天气

<span id="weather"></span><script>function weather(cityName) {    var charset  = (document.charset || document.characterSet || ‘utf-8‘).toLowerCase() == ‘utf-8‘ ? ‘utf-8‘ : ‘gb2312‘;    var cityName = cityName ? cityName : ‘‘;    var oScript  = document.createElement(‘script‘);    oScript.type = "text/javascript"; oScript.async = true;    oScript.src  = http://www.mamicode.com/‘http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&day=0&city=‘+ cityName +‘&dfc=1&charset=‘+ charset;>