This article is mainly on the javascript/jquery get address bar URL parameters of the method is introduced, the need for friends can come to the reference, I hope to help you.
Using jquery to get URLs and using jquery to get URL parameters is the operation we often use 1, jquery get URL is very simple, code as follows code as follows: Window.location.href; Actually just use JavaScript to base the Window object, and do not use jquery knowledge 2, jquery get URL parameters more complex, to use regular expressions, So it's important to learn JavaScript's regular style first look at how simple JavaScript is to get a parameter code in a URL: function geturlparam (name) {var reg = NE W RegExp ("(^|&)" + name + "= ([^&]*) (&|$)"); Constructs a regular expression object containing the target parameter var r = Window.location.search.substr (1). Match (REG); //matching target parameter if (r!=null) return unescape (r[2)); return null; Return parameter value} pass the parameter name in the URL through this function to get the value of the parameter, for example, the URL is http://www.xxx.loc/admin/write-post.php?cid=79 we're going to get the CID value, You can write this: the code is as follows: Geturlparam (' CID '); Understand the way JavaScript gets URL parameters, we can use this method to extend a method for jquery to get URL parameters through jquery, and the following code expands a Geturlparam () method for jquery The code is as follows: (function ($) {$.geturlparam = function (name) {var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)"); var r = window.location.search.substr (1). Match (REG); if (R!=null) return Unescape (r[2]); return null; }) (JQuery); Extended this method for jquery, we can then get the value of a parameter by using the following method code as follows: $.geturlparam (' CID ');