js 实现两个页面表单传值并接收源码
A页面:
function
test(){
var s =document.getElementById("txt");
location.href="2.html?"+"txt="+encodeURI(s.value);
}
第一个页面表单中输入文字或其他值。
B页面代码:
var loc=location.href;
var n1=loc.length;//地址的总长度
var n2=loc.indexOf("=");//取得=号的位置
var id=decodeURI(loc.substr(n2+1, n1-n2));//从=号后面的内容
//alert(id);
document.write(id)
document.getElementById("value1").value=id;
B页面获取传过来的值并显示,也可把传过来的值显示到文本框中。
125jz网原创文章。发布者:江山如画,转载请注明出处:http://www.125jz.com/3602.html