<script type="text/javascript">
function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
        }
       return(false);
}
    </script>


抓值的時侯用<script type="text/javascript">document.write(getQueryVariable("name"));</script>

如果URL中有空白是以%20顯示的話

decodeURI(str)先轉換一下

arrow
arrow
    文章標籤
    javascript get URL variable
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()