父页面通过window.open打开的子页面
father.html
<input type="" name="main" id="mmm" value="123" />
<script type="text/javascript">
$('#Btn').on('click',function(){
window.open('son.html');
});
</script>
son.html
<script type="text/javascript">
alert(window.opener.document.getElementById('mmm').value);
</script>
控制台
Uncaught TypeError: Cannot read property 'value' of null at son.html:21
什么环境下试的,域名是可用的吧
父子窗口间传递数据要用postmessahge
这个需要在服务器测试把。
window.opener 的用法
window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写为:
window.opener.document.getElementById("name").value = "输入的数据";
http://www.jb51.net/article/2...这篇文章有好的解释
我在服务器上面测试可以。但是获取不到father.html的值,可以修改