Reputation: 14038
I have a web-page with a jQuery DOMWindow that loads its content from an iFrame. I need to access elements of the parent window from the iFrame. Is this possible?
This is the configuration for the DOMWindow that is opened 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'm attempting to access the parent window's elements from the DOM box with:
parent.document.getElementById('foo').innerHTML = '';
But this doesn't appear to work. Thanks!
Upvotes: 8
Views: 5817
Reputation: 27364
I see you have jquery as tag so you can do this as below.
$( "#foo", window.opener.document)
OR
window.opener.document.$("#foo")
Upvotes: 5
Reputation: 1897
Change
parent.document.getElementById('foo').innerHTML = '';
to
window.parent.document.getElementById('foo').innerHTML = '';
Upvotes: 8