How to acess parent window object using jquery?
This is my Parent window variable , I want to set its value after closing child window .
$('#serverMsg').html('some text here');
If you are in a po-up and you want to access the opening window, use
The easiest would be if you could load JQuery in the parent window as well:
window.opener.$("#serverMsg").html // this uses JQuery in the parent window
or you could use plain old
document.getElementById to get the element, and then extend it using the jquery in your child window. The following should work (I haven't tested it, though):
element = window.opener.document.getElementById("serverMsg"); element = $(element);
If you are in an iframe or frameset and want to access the parent frame, use
window.parent instead of
According to the Same Origin Policy, all this works effortlessly only if both the child and the parent window are in the same domain.
or you can use another approach:
$( "#serverMsg", window.opener.document )
Here is a more literal answer (parent window as opposed to opener) to the original question that can be used within an iframe, assuming the domain name in the iframe matches that of the parent window:
©2020 All rights reserved.