Js 和Url預設位址列編碼等處理

龐順龍發表於2019-05-11

//處理url引數通用方法
 function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i" );
    var r = window.location.search.substr(1).match(reg);
    if (r != null ) {
        return decodeURIComponent(r[2]);
    }
    return null ;
}


//預設瀏覽器位址列編碼函式是: encodeURIComponent
js處理編碼的解碼函式:decodeURIComponent(r[2]);


龐順龍最後編輯於:4年前

內容均為作者獨立觀點,不代表八零IT人立場,如涉及侵權,請及時告知。

相關文章