比如 a.html?param=1
有什么简洁的方法?

解决方案 »

  1.   

    str.split("?")[1].split("&")[0].split("=");
      

  2.   

    window.location.href.search 貌似是得到?开始后面的东西
     然后自己分析
      

  3.   


    var getQueryString = function(name)
            {
                var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
                if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " ")); return "";
            }以前网上找的 。
      

  4.   

    谁帮我 吧# 转成&  用正则 replace
      

  5.   


    <script>
    var str="dsf###asd#thurt#5456";
    alert(str.replace(/#/g,"&"));
    </script>
      

  6.   


    var str="http:///xxx#ddd#";
    alert(str.replace(/#/g,"&"));
      

  7.   

    String 的replace()方法的返回值是替换后的字符串,原来的对象的值并没有改变。
    即:
    str.replace(/#/g,"&");
    之后,str的值并没有改变。
      

  8.   

    再问一个问题?: (类似if else)语句怎么嵌套?
      

  9.   

    var LK = "a.html?param1=1&param2=2&param3=3";//location.hrefkey = LK.match(/[^?&]+(?==)/g);value = LK.match(/[^=]+(?=&|$)/g)