不是这个
比如我要接收
http://www.sohu.com/test.htm?id=3
id的值请问用js怎么来接收?

解决方案 »

  1.   

    test.htm
    <script>
    alert(window.location.href.split("=")[1]);
    addr="http://www.sohu.com/test.htm?id=3";
    alert(addr.split("=")[1]);
    </script>
      

  2.   

    function getUrlParam(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
      }getUrlParam("id") 结果是3