标签:
<script type="text/javascript"> window.onload=function(){ var box = document.getElementById(‘abox‘); var alinks = box.getElementsByTagName(‘a‘); for (var i = 0; i < alinks.length; i++) { alinks[i].setAttribute("class",""); } var id=0; var parameter = getPar(‘a‘); switch(parameter) { case ‘postidea‘ : case ‘buyidea‘ : case ‘mysale‘ : id = 1; break; case ‘mygift‘: case ‘sendgift‘: id = 2; break; case ‘updatetelphone‘: case ‘updateprofile‘ : case ‘updatepass‘ : case ‘updateavatar‘ : id = 3; break; case ‘alipay‘ : case ‘payin‘ : case ‘payout‘ : id = 4; break; default: id = 0; break; } // whichLink.setAttribute("class","selected"); alinks[id].setAttribute("class","selected"); } function getPar(par){ //获取当前URL var local_url = document.location.href; //获取要取得的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; } </script>
标签:
原文地址:http://www.cnblogs.com/qing-blog/p/4500582.html