I have an iframe and in order to access parent element I implemented following code:
window.parent.document.getElementById('parentPrice').innerHTML
How to get the same result using jquery?
UPDATE: Or how to access iFrame parent page using jquery?
yeah it works for me as well.
Note : we need to use window.parent.document
There are multiple ways to do these.
I) Get main parent directly.
for exa. i want to replace my child page to iframe then
here top.location gets parent directly.
II) get parent one by one,
here if you have more then one iframe, then specify active or visible one.
you also can do like these for getting further parents,
III) get parent by Identifier.
window.parent.document.
jQuery is a library on top of JavaScript, not a complete replacement for it. You don't have to replace every last JavaScript expression with something involving $.
It's working for me with little twist. In my case I have to populate value from POPUP JS to PARENT WINDOW form.
So I have used
$('#ee_id',window.opener.document).val(eeID);
Excellent!!!
Might be a little late to the game here, but I just discovered this fantastic jQuery plugin https://github.com/mkdynamic/jquery-popupwindow. It basically uses an onUnload callback event, so it basically listens out for the closing of the child window, and will perform any necessary stuff at that point. SO there's really no need to write any JS in the child window to pass back to the parent.
If you need to find the jQuery instance in the parent document (e.g., to call an utility function provided by a plug-in) use one of these syntaxes:
window.parent.$
window.parent.jQuery
Example:
jQuery gets attached to the
window
object and that's whatwindow.parent
is.