dom - Javascript window.opener in iframe -
i trying access opener of popup using window.opener reference in popup's script file.
consider following script included in popup.html:
http ://localhost/test/popup.html
<script> alert(window.opener.test_dom); </script>
this works when no iframe involved, see alert message popup.html:
http ://localhost/test/base.html
<html> ... <script> var test_dom = 'test_dom'; var popup = window.open("http://localhost/test/popup.html",... </script> </html>
the problem exists when there 3 files.. container page iframe in launches popup within iframe. not show alert message when popup appears:
c:\testcontainer\container.html
<html> ... <iframe src="http://localhost/test/base.html"> <script> var test_dom = 'test_dom'; var popup = window.open("http://localhost/test/popup.html",... </script> <iframe> </html>
perhaps security restriction? afaik base.html , popup.html in same domain, see no reason why should be. there other ways access opener via other dom attributes in popup.html script? i've been stuck on day now.
other reference opener, else seems work expected in scripts.
using ie 11.
any assistance appreciated!
an iframe
not have window.opener
. has window.parent
(the window in iframe embedded). if parent indeed top level window, perhaps window has window.opener
if actual popup window.
you haven't shown specific html situation, perhaps want iframe this:
window.parent.opener
Comments
Post a Comment