Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select iframe parent from within iframe

Tags:

jquery

iframe

I have an iframe which does picture uploading to give a false sense of Ajax uploading.

This iframe's content has javascript which checks various things and sends status. See it as a progress report almost. Anyway, my page that contains the iframe, is the one showing the data and what not, so I want to change the data on the parent page, from within the iframe. Here is my code:

<div id="iframe_response"></div>
<iframe style="border:none" src="someurl" width="100%" height="350px" id="iframe"></iframe>

And here is my jQuery in the iframe:

$('#iframe_response', "#iframe").append('this should go there but it\'s not...');

It does however not write anything to that div. I have called it on document.ready, but alas...

What am I doing wrong?

like image 607
Bird87 ZA Avatar asked Sep 18 '12 12:09

Bird87 ZA


1 Answers

use parent.document instead of window.parent.document

$(parent.document).find('#whatever')
like image 89
Steven Pribilinskiy Avatar answered Oct 09 '22 15:10

Steven Pribilinskiy