Access to DOM objects of the parent window from jQuery DOMWindow loaded by iFrame

I have a jQuery DOMWindow webpage that loads its contents from an iFrame. I need to access the elements of the parent window from an iFrame. Is it possible?

This is the DOMWindow configuration that opens from my main page:

<script type="text/javascript"> $('.AjaxDOMWindow').openDOMWindow({ anchoredClassName:'DOMWindow', draggable: 1, eventType:'click', height:500, loader:1, loaderHeight:16, loaderImagePath:'/js/jquery/DOMWindow/animationProcessing.gif', loaderWidth:17, positionLeft:0, positionTop:0, positionType:'centered', width:700, windowSource:'iframe' }); 

I am trying to access the elements of a parent window from a DOM field with:

 parent.document.getElementById('foo').innerHTML = ''; 

But that does not work. Thanks!

+7
source share
3 answers

Change

 parent.document.getElementById('foo').innerHTML = ''; 

to

 window.parent.document.getElementById('foo').innerHTML = ''; 
+8
source

I see that you have so that you can do this as shown below.

 $( "#foo", window.opener.document) 

OR

 window.opener.document.$("#foo") 
+4
source

This may also work:

 $(window.parent.document).find("#foo") 
0
source

All Articles