JavaScript write function to quickly get the value of the parameter name in the browser address bar

function getParameter(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = location.search.substr(1).match(reg);
    if (r != null) return (r[2]);
    return null;
}

Function source: ITcast Dark Horse Travel-Travel Route-Parameter Passing

Guess you like

Origin blog.csdn.net/qq_44965393/article/details/113058590