One way to get URL parameters with JavaScript

Source: Internet
Author: User

If the Address bar URL is: abc.html?m=tomms&c=allsearchlist&pageno=1&pagenum=20&text=1

1<script>2     //JavaScript gets the URL and turns the parameter in the URL into an array, and the value of the ARR array is the value of each parameter3     varURL =window.document.location.href.toString ();4     varU = Url.split ("?"));5     vararr = [];6     if(typeof(u[1]) = = "string"){7U = U[1].split ("&");8          for(varIinchu) {9             varA = (U[i].split ("="));TenArr[a[0]] = a[1]; One         } A     } -</script>

Note: When the URL is in Chinese, the Chinese parameters will be garbled!

One way to get URL parameters with JavaScript

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.