JavaScript:獲取網址URL查詢參數

/* 獲取URL查詢參數 */
function getSearch(param){
    var search=location.search.substr(1);
    var locate=search.search(param);
    var paramString='';
    if(locate!==-1){
        var searchRest=search.substr(locate);
        var len=searchRest.length;
        var and=searchRest.search('&');
        if(and==-1){paramString=searchRest.substr(param,len);}
        else{paramString=searchRest.substr(param,and);}
        var paramArray=paramString.split('=');
        return paramArray[1];
    }else{
        return false;
    }
};

 

posted @ 2019-03-08 11:02  漫冬飄雪  阅读(175)  评论(0编辑  收藏  举报