* @param {string} name * @return {string} url */
function getUrlParams() {
    var url = location.search; // Get the "?" in the url The string following the character
    var theRequest = new Object(a);if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=") [0]] = strs[i].split("=") [1]}}return theRequest
}

console.log(getUrlParams()); // {ie: "UTF-8", wd: "indexOf"}
Copy the code
@param {string} name * @return {string} URL parameter value */
function getQueryString(name) {
    var reg = new RegExp('(^ | &)' + name + '= (/ ^ & *) (& | $)'.'i');
    var r = window.location.search.substr(1).match(reg);
    if(r ! =null) {
        return unescape(r[2]);
    }
    return null;
}
console.log(getQueryString('ie')); // UTF-8
Copy the code