最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reference parent window document - Stack Overflow

programmeradmin4浏览0评论

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

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

Share Improve this question asked Mar 26, 2009 at 16:25 LorenzoLorenzo 4,64811 gold badges47 silver badges54 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 12

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 opened the window with window.open(...), check out window.opener

发布评论

评论列表(0)

  1. 暂无评论