简体   繁体   English

从跨域iframe读取父变量

[英]Read parent variable from an cross domain iframe

i know there is a lot of ask about cross domain iframe but i definetly can solve my problem which is : 我知道有很多关于跨域iframe的问题,但是我绝对可以解决我的问题:

On page www.domain_A.com/test.php 在页面www.domain_A.com/test.php

<div id="test">this what i want</div>
<iframe src="http://www.domain_B.com/iframe.html" width="500" height="300" name="myFrame" id="myFrame" style="border:1px solid black;"></iframe>

And www.domain_B.com/iframe.html is this : www.domain_B.com/iframe.html是这样的:

document.domain = "www.multipress.fr";
test = document.getElementById('test'); ;
alert(test);

So i'd like to alert : this is what i want. 所以我想提醒:这就是我想要的。 But as you guess i get security error from Chrome. 但是,正如您猜到的那样,我从Chrome浏览器中收到了安全错误。

So the only solution i see is to integer a script before the iframe to use the postMessage technics. 因此,我看到的唯一解决方案是在iframe之前对脚本进行整数处理以使用postMessage技术。 But before do that, i'd rather check with you if i can find an other solution. 但是在此之前,我宁愿与您联系,是否可以找到其他解决方案。

Thanks a lot for your help. 非常感谢你的帮助。

您只能从父页面访问的是Iframe代码本身-当指向其他域时,内部没有可用内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM