简体   繁体   中英

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

你想要window.opener而不是window.parent (那是帧的)。

You can use context to accessed it:

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

如果您使用window.open(...)打开窗口,请查看window.opener

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM