在js 中根据 url 获取其参数





 function Edit()
         
{
          
var  url  =   window.location+"" ;
       
           
var id=''; 
            
if (url.indexOf('&')==-1)
            
{
              id
=  url.substring(url.indexOf("id=")+3,url.length); 
            }

            
else
            
{    
            
var temp=url.indexOf("&");
          
            id
=url.substring(url.indexOf("id=")+3,url.indexOf("&"));
            
          
            }

            alert(id);
             
           
var page=''
             
             
var urlpage=url.substring(url.indexOf("page="),url.length);
             
              
if (urlpage.indexOf("page=")!=-1)
              
{  
              
                 
if (urlpage.indexOf("&")==-1)
                 
{
                  page
=urlpage.substring(urlpage.indexOf("page=")+5,urlpage.length);
                 }

                 
else
                 
{
                   page
=urlpage.substring (urlpage.indexOf("page=")+5,urlpage.indexOf("&"));
                 }

              }

             
             alert(page);
             alert(urlpage);
             
             
        
var  usersn="";
        
          
var urlsn=url.substring(url.indexOf("usersn="),url.length);
           
if (urlsn.indexOf("usersn")!=-1)
           
{
              
if (urlsn.indexOf("&")==-1)
              
{
                usersn
=urlsn.substring(urlsn.indexOf("usersn=")+7,urlsn.length);
              }

              
else
              
{
                 usersn
=urlsn.substring(urlsn.indexOf("usersn=")+7,urlsn.indexOf("&"));
              }

           }

           
           alert(usersn);
           
           
           
           
            
var username="";
            
             
var urlname=url.substring(url.indexOf("username="),url.length)
              
if (urlname.indexOf("username")!=-1)
                  
{
                     
if(urlname.indexOf("&")==-1)
                    

                 
                     username
=urlname.substring (urlname.indexOf("username=")+9,urlname.length);
                     
                    }

                    
else 
                    
{
                    username
=urlname.substring(urlname.indexOf("username=")+9,urlname.indexOf("&"));
                    
                    }

                    
                  }

                  
                alert(username);
                  
                  
            
          
              
                 
   
          
        
           
          
         }

posted on 2006-06-14 12:02  gwazy  阅读(804)  评论(0编辑  收藏  举报

导航