JS URL相关

1、获取url参数

function getUrlParam(k) {
    var regExp = new RegExp('([?]|&)' + k + '=([^&]*)(&|$)');
    var result = window.location.href.match(regExp);
    if (result) {
        return decodeURIComponent(result[2]);
    } else {
        return null;
    }
}

 

posted @ 2019-09-05 14:15  一只桔子2233  阅读(122)  评论(0)    收藏  举报