// body onload var area1=""; var area2=""; var endspan=""; function init_page(){ area1 = getPar('area1'); area2 = getPar('area2'); endspan = getPar('endspan'); // 默认有城市 // click_xshuaxin(); var c_address1 = document.getElementById("c_address1"); var c_address2 = document.getElementById("c_address2"); var city_listHTML = ''; var cstr1 = ''; var myArray = new Array(); myArray[0] = '上海'; // myArray[1] = '苏州'; // myArray[2] = '杭州'; // myArray[3] = '常州'; // myArray[4] = '嘉兴'; // myArray[5] = '湖州'; // myArray[6] = '扬州'; for (var i=0;i<myArray.length;i++) { cstr1 = myArray[i]; if (cstr1 == area1){ city_listHTML +='<li id="li'+(i+1)+'" class="c_button" style="background:#00cc9c;color:#ffffff;border-color:#00cc9c;" onclick="c_get_target_area('+'\''+myArray[i]+'\''+')">'+myArray[i]+'</li>'; }else{ city_listHTML +='<li id="li'+(i+1)+'" class="c_button" onclick="c_get_target_area('+'\''+myArray[i]+'\''+')">'+myArray[i]+'</li>'; } } c_address1.innerHTML = city_listHTML; if(area1=="false"){ document.getElementById("li1").style.color="#FFFFFF"; document.getElementById("li1").style.background="#00cc9c"; document.getElementById("li1").style.border="2px solid #00cc9c"; } var sightspot_listHTML = ''; var cstr2 = ''; var myArray2 = new Array(); myArray2[0] = '千岛湖'; myArray2[1] = '乌镇'; myArray2[2] = '萧山机场'; myArray2[3] = '西塘'; /* myArray2[0] = '千岛湖'; myArray2[1] = '安吉'; myArray2[2] = '天目湖'; myArray2[3] = '南山竹海'; myArray2[4] = '乌镇'; myArray2[5] = '同里'; myArray2[6] = '留园'; myArray2[7] = '灵山大佛'; myArray2[8] = '甪直'; myArray2[9] = '锦溪'; myArray2[10] = '周庄'; myArray2[11] = '萧山机场'; myArray2[12] = '恐龙园'; myArray2[13] = '嬉戏谷'; myArray2[14] = '大明山'; myArray2[15] = '青山湖'; myArray2[16] = '西塘'; myArray2[17] = '南浔'; myArray2[18] = '桐庐'; myArray2[19] = '莫干山'; */ for (var i=0;i<myArray2.length;i++) { cstr2 = myArray2[i]; if(area1==cstr2){ sightspot_listHTML +='<li id="li'+(i+6)+'" class="c_button" style="background:#00cc9c;color:#ffffff;border-color:#00cc9c;" onclick="c_get_target_area('+'\''+myArray2[i]+'\''+')">'+myArray2[i]+'</li>'; }else{ sightspot_listHTML +='<li id="li'+(i+6)+'" class="c_button" onclick="c_get_target_area('+'\''+myArray2[i]+'\''+')">'+myArray2[i]+'</li>'; } } c_address2.innerHTML = sightspot_listHTML; } // 选中一个城市 function c_get_target_area(area){ area1=area; // 用一个新的页面打开 var listURL = "../index.html?area1="+area1+"&area2="+area2+'&endspan='+endspan; // 跳转前将URL编码 listURL = encodeURI(listURL); window.location.href = listURL; } // 刷新坐标位置 function click_xshuaxin(){ var c_address = document.getElementById("c_address"); var addHTML = ''; addHTML +='<li id="c_currentLocation" class="c_choose sh xc_choose" onclick="c_get_target_area('+'\''+"上海"+'\''+')">上海</li>'; c_address.innerHTML = addHTML; // 将景区改为热门城市 var c_hotpush = document.getElementById("c_hotpush"); var pushHTML = ''; pushHTML+='<p>热门城市</p>'; pushHTML+='<div class="xxian3"></div>'; pushHTML+='<ul class="c_address">'; pushHTML+='<li class="c_button"><span id="c_btn-sh" onclick="c_get_target_area('+'\''+"上海"+'\''+')">上海</span></li>'; // pushHTML+='<li class="c_button"><span id="c_btn-hz" onclick="c_get_target_area('+'\''+"北京"+'\''+')">北京</span></li>'; // pushHTML+='<li class="c_button"><span id="c_btn-nj" onclick="c_get_target_area('+'\''+"厦门"+'\''+')">厦门</span></li>'; // pushHTML+='<li class="c_button"><span id="c_btn-zs" onclick="c_get_target_area('+'\''+"福州"+'\''+')">福州</span></li>'; c_hotpush.innerHTML = pushHTML; } // 从上一页的链接上获取参数 function getPar(par){ //获取当前URL var local_url = document.location.href; // 接收的时候将URL 解码 local_url = decodeURI(local_url); //获取要取得的get参数位置 var get = local_url.indexOf(par +"="); if(get == -1){ return false; } //截取字符串 var get_par = local_url.slice(par.length + get + 1); //判断截取后的字符串是否还有其他get参数 var nextPar = get_par.indexOf("&"); if(nextPar != -1){ get_par = get_par.slice(0, nextPar); } return get_par; }