JS get URL Address parameter

Source: Internet
Author: User

<script>varurl = "http://127.0.0.1/index.php?old_quantity=168&date=1478309879000$id=2";//Defining Variables        functionParse_url (_url) {//Defining Functions         varPattern =/(\w+) = (\w+)/ig;//Defining Regular Expressions         varParames = {};//Defining ArraysUrl.replace (Pattern,function(A, B, c) {Parames[b]=C;          }); /*This is the most critical. When replace matches to date=1478309879000. Then use the Execute function (a,b,c), where A is the value: Date=1478309879000,b is the value of date,          The value of C is 1478309879000; (this is a reverse reference.) because there are two sub-matches when defining a regular expression.)          It then assigns the value of the array key to date to 1478309879000, and then completes.          Continue to match to id=2; Execute function (a,b,c), where a is the value of Id=2,b, the value of Id,c is 2, and the value of the array's key is the ID of 2. */         returnParames;//returns the array.        }        varparames = Parse_url (URL);//call function, incoming URL        varDate = parames[' Date '];//gets the value of date        varDates = DATE.SUBSTR (0, 10)//intercept the Required string        //Convert date format        functionGetlocaltime (NS) {return NewDate (parseint (NS) *). toLocaleString (). Replace (/:\d{1,2}$/, ");             } alert (Getlocaltime (dates)); </script>

JS get URL Address parameter

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.