javascript获取链接值
来源: 时间:2010-06-01 点击:次
用JS怎样才能获得i和q的值??
http://localhost/?i=1&q=2
用JS怎样才能获得i和q的值??
解决方案:
<script>
var $_GET = new Object();
var _Rep = document.location.search.replace(/(\?|&)([\w\d_]+)=([^&]+)/g, "_GET['$2']='$3';$");
eval('$'+unescape(_Rep.substr(0,_Rep.length-1)));
if(location.href.indexOf('?') == '-1') location.href='?a=呵呵&b=哈哈';
for(i in $_GET) document.write(i+'=>'+$_GET[i]+'<br>');
</script>