解决方案 »

  1.   

    查下location的属性,然后看下它的一些属性
      

  2.   

    http://localhost/index.html?type=country&id=12&page=10
      <script type="text/javascript">
    var url = window.location;
    function getUrlParam(url,name){
    var pattern = new RegExp("[?&]" + name +"\=([^&]+)","g");
    var matcher = pattern.exec(url);
    var items = null;
    if(matcher != null){
    try{
    items = decodeURIComponent(decodeURIComponent(matcher[1]));
    }catch(e){
    try{
    items = decodeURIComponent(matcher[1]);
    }catch(e){
    items = matcher[1];
    }
    }
    }
    return items;
    } alert(getUrlParam(url,'type')); // country
    alert(getUrlParam(url,'id')); // 12
    alert(getUrlParam(url,'page')); // 10  </script>
    另外function名应该叫getUrlParam而不是getUtlParam吧。
      

  3.   

    上面我写的url返回的是上一个页面的URL,而我想得到的参数在上一个页面的本页面URL中,location的一些属性只能得到本页面的url!
      

  4.   

    Quote: 引用 2 楼 fdipzone 的回复:

    你这个是获取本页面连接中的参数吧?我想获取从上一个页面超链接传过来的参数,怎么破?
    函数名那个没有关系吧!
      

  5.   

    var url = "www.zhangyunling.com?aada=adaa&adad=adasd&sdfs=asdad#did",
    reg = /([^\=\?|\&]+)\=([^\=\&\#]+)/g;
    var aa = url.match(reg);

    console.log(aa);
    url.replace(reg,function($1,$2,$3){
    console.log($2+"="+$3);
    });看你的意思,是不是想要使用正则表达式实现?
    试试这样可以得到你想要的结果不。
      

  6.   


    當前頁面url後面的參數就是上一頁的超鏈接跳過來的,有什麼問題?
    你不是要獲取上一頁傳過來的參數麼?