JS gets the parameters of the URL

Source: Internet
Author: User
Online looking for a piece of code, very useful, it is difficult to find the original author, but thank you very much!
/** * Gets the current URL parameter value * @param name Parameter name * @return parameter value */function Geturlparam (name) {var reg = new RegExp ("(^|&)" + Nam E + "= ([^&]*) (&|$)", "I"), var r = window.location.search.substr (1). Match (REG), if (r! = null) return unescape (r[2 ]); return null; }
Note: No matter how many parameters can be obtained, just pass the correct and consistent parameter names such as:
url:http://xxx.aspx?requestid=15&number=2015121501
You want to get RequestID, call the function Geturlparam (RequestID);
To get number, call the function Geturlparam (number);

JS gets the parameters of the URL

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.