例如:  window.location.href="Main.html?num=1"; 
  我要怎么获得num的值呢?急

解决方案 »

  1.   

    静态的话用JS来获取浏览器的参数
    <Script language="javascript">function GetRequest() {   var url = location.search; //获取url中"?"符后的字串   var theRequest = new Object();   if (url.indexOf("?") != -1) {      var str = url.substr(1);      strs = str.split("&");      for(var i = 0; i < strs.length; i ++) {         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);      }   }   return theRequest;}</Script>参考下,可获取?后多个参数
      

  2.   

    通过调用此函数获取对应参数值:<Script language="javascript">var Request = new Object();Request = GetRequest();var 参数1,参数2,参数3,参数N;参数1 = Request['参数1'];参数2 = Request['参数2'];参数3 = Request['参数3'];参数N = Request['参数N'];</Script>以此获取url串中所带的同名参数
      

  3.   

    js的话解析urlphp的话$_GET['num']jsp的忘记了,其实就是和GET方式提交form一样的
      

  4.   


    String.prototype.getQueryString = function(name)   
    {   
       var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;   
       if ( r=this.match(reg) ) return unescape(r[2]);   
       return null;   
    }  
    var url=window.location.href;
       var _para = url.getQueryString("area");  
       alert(_para);
      

  5.   

    如果是动态的JSP的获取方式的话是:
    request.getParameter("num")