Get parameter example in Url encapsulated by jQuery _ jquery

Source: Internet
Author: User
When processing Javascript on the frontend only, you may encounter a problem of passing a webpage parameter to the next page through the get method. In this case, you can obtain the Get parameter in the Url, as shown below, if you need it, you may encounter the problem of passing a webpage parameter to the next page by referring to the pure foreground processing of js.

In this case, you can use js to obtain the get parameter in the url of the current page. The core statement is:

Window. location. href

The detailed code is not explained. If there is a comment, you can understand it. It is encapsulated into a jQuery extension package.

The Code is as follows:


(Function ($ ){
$. Extend ({
/**
* Url get parameters
* @ Public
* @ Return array ()
*/
UrlGet: function ()
{
Var aQuery = window. location. href. split ("? "); // Get the Get Parameter
Var aGET = new Array ();
If (aQuery. length> 1)
{
Var aBuf = aQuery [1]. split ("&");
For (var I = 0, iLoop = aBuf. length; I {
Var aTmp = aBuf [I]. split ("="); // separate the key and Value
AGET [aTmp [0] = aTmp [1];
}
}
Return aGET;
},
});
}) (JQuery );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.