标签:
第一个页面:
<a href="index2.html?name=任晓强&age=29">nihao</a>
第二个页面:
var str = location.search, ary = str.substring(1).split("&"),//substring str中从第二个字母开始选择,split把字符串改成数组并用&间隔两个数据 endary = [], i = 0, len = ary.length; console.log(ary,len); for(;i<len;i++){ var name = decodeURIComponent(endary[0]); endary[i] = ary[i].split("=")[1];//ary[i]数组里面的数据用split转成数组并选择=后的数据 } console.log(endary); test.innerHTML = "姓名:"+name+"<br>年龄:"+endary[1];
标签:
原文地址:http://www.cnblogs.com/xupeiyu/p/4677417.html