The JS request function is used to obtain url parameters.

Source: Internet
Author: User

Copy codeThe Code is as follows:
Function request (strParame ){
Var args = new Object ();
Var query = location. search. substring (1 );

Var pairs = query. split ("&"); // Break at ampersand
For (var I = 0; I <pairs. length; I ++ ){
Var pos = pairs [I]. indexOf ('= ');
If (pos =-1) continue;
Var argname = pairs [I]. substring (0, pos );
Var value = pairs [I]. substring (pos + 1 );
Value = decodeURIComponent (value );
Args [argname] = value;
}
Return args [strParame];
}

For example, if you want to obtain aaa. aspx? Id = 2

Usage: var id = request ('id ');

Below are some articles for Reference
Js extension instance used to obtain url parameters
JQuery plugin for getting URL parameters
Garbled characters caused by passing Chinese parameters in JS URLs

Related Article

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.