js获取URL参数

       var ID= getParam('ID');//获取ID


        var getParam = function (name) {
            var search = document.location.search;
            var pattern = new RegExp("[?&]" + name + "=([^&]+)", "g");
            var matcher = pattern.exec(search);
            var items = null;
            if (null != matcher) {
                try {
                    items = decodeURIComponent(decodeURIComponent(matcher[1]));
                } catch (e) {
                    try {
                        items = decodeURIComponent(matcher[1]);
                    } catch (e) {
                        items = matcher[1];
                    }
                }
            }
            return items;
        };
    </script>
喜欢的朋友请帮忙点个赞!!!
原文地址:https://www.cnblogs.com/mchuang/p/5001034.html