首頁 >web前端 >js教程 >javascript取得URL參數與參數值的範例程式碼_javascript技巧

javascript取得URL參數與參數值的範例程式碼_javascript技巧

WBOY
WBOY原創
2016-05-16 17:08:021001瀏覽
複製程式碼 程式碼如下:

<script><BR>                  function goto_url(url){<🠎  .usteel.com/index.php?app=list_release";<BR>                      var d_date = getParameter("date",url);<BR>                    if(d_date    new_url = "&" d_date;<BR>                    }<🠜) ("物種",url) ; <BR>                      if(物種!= ''){<BR>     <BR>                     }<BR><BR>                           }<BR>                  //javascript取得指定參數及其對應的值  <BR>                      {  <BR>                          //取得URL中全部參數清單資料  <BR>                      var str = "&" url.split("?")[1];  < paraName = paraStr "=";  <BR>                      //判斷要取得的參數是否為有indexOf("&" paraName)!=-1)  <BR>                      {      //如果要取得的參數到結尾是否還包含「&」  <BR>                        str.length).indexOf("&")!=-1)  <BR>                                    //得到要取得的參數到結尾的字串  <BR>               ),str.length);  <BR>                                               result=TmpStr.substr(TmpStr.indexOf(paraName),TmpStr.indexOf("&" )-TmpStr.indexOf(paraName));    <BR>                              else  <BR>                                   result=str.substring(str.indexOf(paraName),str.length);    <BR>       }    <BR>                      else  <BR>                              result="";    <BR>    <BR>                      return (result.replace("&",""));                    </script>


下列範例已完整測試


複製程式碼 程式碼如下:


     
     
   
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn