window.location.search.split("id=")[1]就是你的10这里只是举例说的具体URL是window.location.href这个字串,自己分离出来吧...

解决方案 »

  1.   

    a.htm
    ////////////////////
    <SCRIPT>
    function getUrlParameter(asName){
     var lsURL=window.location.href;
     loU = lsURL.split("?");
     if (loU.length>1){  var loallPm = loU[1].split("&");  for (var i=0; i<loallPm.length; i++){
       var loPm = loallPm[i].split("=");
       if (loPm[0]==asName){
        if (loPm.length>1){
         return loPm[1];
        }else{
         return "";
        }
       }
      }
     }
     return null;
    }alert(getUrlParameter("id"));
    </SCRIPT>
      

  2.   

    给你两段代码看看应该就懂了
    // from.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
    <title>Untitled Document</title>
    </head>
    <script>
    function moveValue()
    {
        var str = document.all.from.value;
    window.location.href = "to.html?from=" + str;
    }
    </script>
    <body>
    <form>
    <center>
    <input name="from" type="text">
    <input name="btn" type="button" value="button" onClick="moveValue();">
    </center>
    </form>
    </body>
    </html>
    //to.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
    <title>Untitled Document</title>
    </head>
    <script>
    var sHref = window.location.href;
    var sArgName = "to";
    function init(sHref,sArgName)
    {
    var args  = sHref.split("?");
    var retval = "";
    if(args[0] == sHref){
        return;
    }
    var str = args[1];
    var arg = str.split("=");
    if(arg.length <= 1){
        return;
    }
    retval = arg[1];
    document.all.to.value = retval;
    return retval;
    }
    </script>
    <body onLoad="init(sHref,sArgName);">
    <form>
    <center>
    <input name="to" type="text">
    </center>
    </form>
    </body>
    </html>从from按按钮到to,to接受from传过来的值
      

  3.   

    window.location
    hash 设置或获取 href 属性中在井号“#”后面的分段。 
    host 设置或获取 location 或 URL 的 hostname 和 port 号码。 
    hostname 设置或获取 location 或 URL 的主机名称部分。 
    href 设置或获取整个 URL 为字符串。 
    pathname 设置或获取对象指定的文件名或路径。 
    port 设置或获取与 URL 关联的端口号码。 
    protocol 设置或获取 URL 的协议部分。 
    search 设置或获取 href 属性中跟在问号后面的部分。 
      

  4.   

    测试例
    <script>
    url = location.search.substr(1);
    if(url.length > 0) {
      ar = url.split(/[&=]/);
      for(i=0;i<ar.length;i+=2) {
        document.write("参数:"+ar[i]+":"+ar[i+1]+"<br>");
        eval(ar[i]+"='"+ ar[i+1]+"'");
      }
      document.write("变量room:"+room+"<br>");
      document.write("变量a:"+a+"<br>");
    }
    </script><a href='?a=你好&room=awe'>test</a>
      

  5.   

    <script>
    var JSvar=<%=request.getParameter('id')%>
    </script>
      

  6.   

    在 xxx.html?id=10 页面里:
    <script language="javascript">
    String.prototype.getQueryString = function(name)
    {
      var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;
      if (r=this.match(reg)) return unescape(r[2]); return null;
    };alert(window.location.href.getQueryString("id"));
    </script>
      

  7.   

    楼上的解决方法应该都可以,如果参数比较多就应该用indexOf和substring两个函数来处理
      

  8.   


    <script>
    url = location.search.substr(1);
    if(url.length > 0) {
      ar = url.split(/[&=]/);
      for(i=0;i<ar.length;i+=2) {
        document.write("参数:"+ar[i]+":"+ar[i+1]+"<br>");
      }
    }
    </script><a href='?a=你好&room=awe'>test</a>参数参考
    window.location
    hash 设置或获取 href 属性中在井号“#”后面的分段。 
    host 设置或获取 location 或 URL 的 hostname 和 port 号码。 
    hostname 设置或获取 location 或 URL 的主机名称部分。 
    href 设置或获取整个 URL 为字符串。 
    pathname 设置或获取对象指定的文件名或路径。 
    port 设置或获取与 URL 关联的端口号码。 
    protocol 设置或获取 URL 的协议部分。 
    search 设置或获取 href 属性中跟在问号后面的部分。
      

  9.   

    var strParameter = window.location.search.substring(1);
    var id = strParameter.split('&')[0].split('=')[1];
      

  10.   

    function get_id(){
       return location.href.split('id=').pop();
    }