A sample of Get parameters in the fetch URL in jquery encapsulation _jquery

Source: Internet
Author: User

JS Pure foreground processing will encounter a page of parameters, through get way, passed to the next page of the problem.

You can now use JS to get the parameters in the URL of the current page. The core statement is:

Window.location.href

Detailed code does not explain, there are comments, you read it. Encapsulated into a jquery expansion pack.

Copy Code code as follows:

(function ($) {
$.extend ({
/**
* URL Get parameters
* @public
* @return Array ()
*/
Urlget:function ()
{
var aquery = Window.location.href.split ("?"); /Get getting parameters
var aget = new Array ();
if (Aquery.length > 1)
{
var abuf = Aquery[1].split ("&");
For (var i=0, iloop = abuf.length; i<iloop; i++)
{
var aTmp = abuf[i].split ("=");//separating 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.