Lorenzo
Lorenzo

Reputation: 4648

Reference parent window document

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

Upvotes: 5

Views: 12099

Answers (3)

aprian
aprian

Reputation: 33

You can use context to accessed it:

<script type="text/javascript">
    $(document).ready(function(){
        var content = $("#summary",window.opener.document).html();
    });
</script>

Upvotes: 3

user7094
user7094

Reputation:

If you opened the window with window.open(...), check out window.opener

Upvotes: 2

Greg
Greg

Reputation: 321578

You want window.opener not window.parent (that's for frames).

Upvotes: 12

Related Questions