When cross-domain, use a URL to pass data and take values.

Source: Internet
Author: User
Tags vars

Many times, we often encounter cross-domain situations, such as a.html's data to be used in b.html.

Then, we can pass the data through the URL to achieve the way:

Like my data on the a.html page: codeid=2 Username=lee Checkname=kay want to pass the URL to the b.html page

Well, we can do this in the URL of the b.html page B.html?codeid=2&username=lee&checkname=kay

Note that there is a need to use "&" to connect multiple data.

Then, we can go to the b.html page to take the value operation.

1 functionTransferurlqueryvariables () {2     varSearch =Window.location.search,3 Query,4 VARs,5VarMap = {};6 7     if(!search | | Search.length < 2) {8         returnVarMap;9     }Ten  Onequery = search.substring (1); AVARs = Query.split (' & ')); -  -      for(vari = 0, pair, length = vars.length; i < length; i++) { thePair = vars[i].split (' = ')); -Varmap[decodeuricomponent (pair[0])] = decodeURIComponent (pair[1]); -     } -      +     returnVarMap; -}

In this way, it is no problem to take values across domains.

When cross-domain, use a URL to pass data and take values.

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.