HTML +传递参数 b/w Parent &孩子
这可能很简单,但有趣的是我已经尝试了近 2-3 小时但无法解决它:(。
我有一个父窗口,其中有一个文本框,并且它有一个值。我做了一个 window.open 并打开一个客户端并尝试读取父项的值,但无法获取该值
)
我尝试过
window.parent.document.getElementById(window.name )
window.parent.document.getElementById('test').value
window.opener.document.getElementById('teast').value
window.parent.opener.document.getElementById('teast').value
window.opener.parent.document.getElementById('teast').value
几乎所有的排列组合。而且是纯 HTML。
It might be a simple, but the funny thing is i've tried it for almost 2-3hrs and haven't been able to solve it :(.
I have a parent window, which has a text box, and it has a value. I do a window.open and open a client and try to read the value of the parent, but unable to get the value.
Any help!!
I've tried
window.parent.document.getElementById(window.name)
window.parent.document.getElementById('test').value
window.opener.document.getElementById('teast').value
window.parent.opener.document.getElementById('teast').value
window.opener.parent.document.getElementById('teast').value
Almost all the permutation and combination. And its pure HTML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于安全限制,Javascript 无法访问驻留在与当前域不同的域中的文档。因此,如果您的父母与孩子位于不同的域中,则这将永远起作用。
Due to security restrictions, Javascript is unable to access documents that reside on a separate domain from the current one. So, if your parent is on a different domain from the child, this will never work.
window.opener.document.getElementById('test').value
应该可以工作。window.opener.document.getElementById('test').value
should work.我已经尝试过,它不起作用。我发布代码
test.html
child.html
I've tried that, it ain't work. I'm posting the code
test.html
child.html