如何在javascript中找到父窗口的标题? [英] How can I find the title of parent window in javascript?

查看:57
本文介绍了如何在javascript中找到父窗口的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在javascript中找到父窗口的标题?

How can I find the title of parent window in javascript?

我使用

 alert(window.parent.document.FormName);  

 alert(window.parent.document.title);

 alert(window.parent.parent.document.title);

但结果不正确.

推荐答案

将此代码用于您的解决方案

use this code for your solution

  1. pageMain.html

  1. pageMain.html

<html>
<head>
    <title>Parent Window</title>
</head>
<body>
<input type="text" id="data" value="23444" />
<a href="#" onclick="javascript:openChildWindow();">Open Child Popup window</a>
</body>
<script>
function openChildWindow() {
    window.open('page1.html','childWindow','width=400,height=400');
}
</script>
</html>

  • page1.html

  • page1.html

    <html>
    <head>
        <title>Child Window</title>
    </head>
    <body onload="initializeMainDiv();">
        <div id="mainDiv"></div>
    </body>
    <script>
    function initializeMainDiv() {
       alert( window.opener.document.title )
      }
      </script>
    </html>
    

  • 这篇关于如何在javascript中找到父窗口的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆