[ 轉 ] 利用javascript 取得 GET 變數
liang | 2010-02-06 14:29:02 | PHP
來源:http://bbs.mychat.to/reads.php?tid=545172
<script>
var url=window.location.toString();
var str="";
if(url.indexOf("?")!=-1){ //url裡有"?"符號
var ary=url.split("?")[1].split("&");
for(var i in ary){
str+=ary[i].split("=")[0]+":"; //變數名稱
str+=ary[i].split("=")[1]+"\n"; //變數值
}
}else{ //url裡沒有"?"符號
str+="沒有get變數\n";
}
window.alert(str);
</script>
========================================================================
相關文章
意見反應
發表意見
Powered by Liang | Hosted by TWIX.idv.tw | UI Designed by Liang & Bluefly |

2.0|XML