使用javascript获取Url的参数

  <script language=javascript>
   //获取url的参数
   function GetUrlParams()
   {
       //获取参数串
       var args = new Object();
    var search = location.search.substring(1);
    if(search != '')
    {
      var params = search.split('&');
      for(i = 0;i < params.length;i++)
      {
      var pos = params[i].indexOf
('=');
      var key = params[i].substring
(0,pos);
      var value = params
[i].substring(pos+1);
      args[key] = value;
      }
    }
    return args;
   }
   
   var args = GetUrlParams();
   alert(args['param']);
  </script>

posted on 2009-03-08 23:32  Dot-Boy  阅读(250)  评论(0编辑  收藏  举报