0

i have simple html webpage, guess main page domain is mainDomain.com . This webpage contain <iframe id="a1" src="http://crossdomain.com/page1.htm"> tag and this <iframe> tag src is cross domain. The <iframe id="a1" src="http://crossdomain.com/page1.htm"> contain one more <iframe> tag and thats src <iframe id="a1" src="http://mainDomain.com/page2.html">

I want to get content of<iframe id="a1" src="http://crossdomain.com/page1.htm">, using main page or <iframe id="frame2">. please help me ,how can i do this?

<!doctype>
<html>
<head></head>

<body>
<h1>hello world</h1>
<iframe src="http://crossdomain.com/page1.htm"  id="frame1">         
     <h2 id="hader1" > hey dad </h2>            
        <iframe src="http://mainDomain.com/page2.html" id="frame2">
          <p>this is second frame</p>
        </iframe>            
</iframe>
</body>
</html>
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
  • 2
    No cross-domain access, unless you can [control the other domain](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy). – Teemu Apr 16 '15 at 17:40
  • i want to do this any way , please suggest me a way – Jaydeep Parakhiya Apr 16 '15 at 17:50
  • 1
    [You simply can't](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript) with JS. – Teemu Apr 16 '15 at 17:52
  • Use a server and something like cURL to download the content on the server. That's about the extent, the browser won't give you access in the browser, unless you author a browser extension. – Jared Farrish Apr 17 '15 at 00:12

1 Answers1

-1

If i understant your question corrcectly , you wanna get contents from <iframe id="frame2"> into <iframe id="frame1">.

and i deem that JQuery is useful way to get contents as cross-domain access.

<script>
$('#frame1').load(function(){
    $('#frame').contents().find('#hader1').text();
});
</script>
qianjiahao
  • 399
  • 1
  • 3
  • 10