js method Gets the arguments passed by the Get mode.

Source: Internet
Author: User

There are two ways to do this: for example, URL: http://h5.49you.com/reg.html?sid=1&a=2&b=3&c=4

1. function getquerystring (name) {

var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)", "I");
var r = window.location.search.substr (1). Match (REG);
if (r!=null) return (r[2]); return null;

var sid = GetQueryString ("Sid");

var a = getquerystring ("a");

var B = getquerystring ("B");

var c = getquerystring ("C");

2, var $_get = (function () {
 var URL = Window.document.location.href.toString ();
 var u = url.split ("?");
 if (typeof (u[1]) = = "string") {
   u = U[1].split ("&");
   var get = {};
   for (var i in u) {
     var j = u[i].split ("=");
     get[j[0]] = j[1];
   return get;
 } else {
    return {};
}) ();

var sid=ad = $_get[' sid ');

var a=ad = $_get[' a '];

var b=ad = $_get[' B '];

var c=ad = $_get[' C ');

js method Gets the arguments passed by the Get mode.

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.