tags:

views:

58

answers:

2

The iframe is something like this:

<iframe frameborder="0" src="http://www.another-domain.com/whatever.php"&gt;
<html>
<head>....</head>
<body>
....
....
<div div="mydiv">.....</div>
</body>
</html>
</iframe>

I want to access #mydiv from the parent window. The iframe contents are from another domain.

+1  A: 

If its cross-domain id ont think youll be able to do it. Iframes are subject to the same "same domain" policies as ajax i believe.

prodigitalson
+1  A: 

Hmmm... from a totally different domain? If so, then I'm afraid you won't be able to do this. That's called "cross-site-scripting" and browsers don't allow that to happen.

However, if you are parent-page is parent.domain.com and your child is on child.domain.com, then you can access the contents of the iframe using the window object:

child_frame = document.getElementById('myFrameId');
inner_div = child_frame.document.getElementById('mydiv');
/* now do stuff with inner div */

I'm pulling that off the top of my head: YMMV!

uotonyh
You'd want child_frame = $('iframe'), since he specified that the iframe has no id.
bluej100
Ah! Yes, of course. And JQuery, as well. Thanks!
uotonyh