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.