how to access iFrame parent page using jquery?

how to access iFrame parent page using jquery?

I have an iframe and in order to access parent element I implemented following code:

How to get the same result using jquery?
UPDATE: Or how to access iFrame parent page using jquery?


Solution 1:

To find in the parent of the iFrame use:

$('#parentPrice', window.parent.document).html();

The second parameter for the $() wrapper is the context in which to search. This defaults to document.

Solution 2:

how to access iFrame parent page using jquery


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 $.

Solution 3:

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



jQuery gets attached to the window object and that’s what window.parent is.

Related:  Best javascript syntactic sugar

Solution 4:

You can access elements of parent window from within an iframe by using window.parent like this:

// using jquery    

Which is the same as:

// pure javascript

And if you have more than one nested iframes and you want to access the topmost iframe, then you can use like this:

// using jquery$("#element_id");

Which is the same as:

// pure javascript"element_id");

Solution 5:

in parent window put :

function ifDoneChildFrame(val)

and in iframe src file put :

<script>window.parent.ifDoneChildFrame('Your value here');</script>

Solution 6:

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);