1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 一个Html页面给另一个html页面传值(或B.html页面调用A.html的参数)

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

时间:2021-06-18 06:50:56

相关推荐

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

自己项目中需要用到,很多朋友已经解决了这个问题,有好几种方法,但是我急用,就用了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>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。