自己项目中需要用到,很多朋友已经解决了这个问题,有好几种方法,但是我急用,就用了window.open方法先总结一个自己立马上手的方法,等周末或中间有空把其他方法也总结一下,主要希望自己以后再用到的时候万一忘了能快速回忆起来,也希望能帮助一下需要的朋友

A.html

                <input type="text" name="username" class="username" />
		<input type="text" name="username" class="username" />
		<input type="text" id="n" name="n"/>
		<button type="submit" id="open">打开新的页面</button>
		<script>
			u = [];
			$('#open').click(function() {
				var un = document.getElementsByName("username");
				var len = un.length;
				alert(len)
				for(i = 0; i < len; i++) {
					var ne = un[i].value;
					u.push(ne);
				}
				document.getElementById("n").value = u; 
				var ss = $('#n').val();
				alert(ss);  
				window.open('Intercept.html') //B.html 前面的是不重要,关键的是这句 
			})
		</script>

B.html

<script>
        //用window.opener. 
	var content = window.opener.document.getElementById("n").value;
	alert(content);
</script>

 

更多推荐

一个Html页面给另一个html页面传值(或B.html页面调用A.html的参数)