联系我们 更多>>
  • 地址:西安经济技术开发区中环大厦A座18F-A
  • 电话:029-83765753
  • Q Q:374676511
当前位置:首页 >> Javascript >> 正文

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>