<script type= "Text/javascript" >functionGeturlparam (name) {varReg =NewRegExp ("(^|&)" + name + "= ([^&]*) (&|$)");//constructs a regular expression object that contains a target parametervarr = Window.location.search.substr (1). Match (REG);//Match target Parametersif(r!=NULL)returnUnescape (r[2]);return NULL;//Return parameter Values} Alert (Geturlparam ( ' cc '));</script>
Geturlparam This method is to get the URL after the URL through the regular to parse, when used, such as red Alert, CC is the name of the parameter
Understand the way JavaScript gets URL parameters, we can extend a method for jquery to get URL parameters through jquery, the following code expands a Geturlparam () method for jquery
(functionfunction(name) {varnew RegExp ("(^|&)" + name + "= ([^&]*) (&|$) "); var r = window.location.search.substr (1). Match (reg); if (r!=nullreturnreturnnull;}}) (jQuery);
After extending this method for jquery, we can get the value of a parameter in the following way
$.getUrlParam(
‘cid‘
);
If you're not sure how to add extension methods to jquery, you can refer to the jquery Plugin development tutorial
jquery or JS get URL parameters