I'm trying to access the parent window document from a popup.
<script type='text/javascript'>
$(document).ready(function(){
var summary = window.parent.document.getElementById('summary');
var content = summary.innerHTML;
});
</script>
Is it even possible? Is there a jQuery specific way to do it?
Thanks
The Window.parent property is a reference to the parent of the current window or subframe. If a window does not have a parent, its parent property is a reference to itself. When a window is loaded in an <iframe>, <object>, or <frame>, its parent is the window with the element embedding the window.
The Window.parent property is a reference to the parent of the current window or subframe. If a window does not have a parent, its parent property is a reference to itself.
winobj=window.open (..) ... We can even have a function with arguments and use it as a workaround to share data between parent and child browser windows at some scenarios as shown below: window.opener.functioname (arg1,arg2,..)
We can access the child window elements by using the window handle that will be returned by the window.open () method, as shown below: winobj=window.open (..) ... The winobj is actually a window object instance of the newly created window.
You want window.opener
not window.parent
(that's for frames).
You can use context to accessed it:
<script type="text/javascript">
$(document).ready(function(){
var content = $("#summary",window.opener.document).html();
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With