简体   繁体   中英

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 :

On page 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 :

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.

So the only solution i see is to integer a script before the iframe to use the postMessage technics. But before do that, i'd rather check with you if i can find an other solution.

Thanks a lot for your help.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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