将数据从子Javascript页面传递到父Javascript页面

将数据从子Javascript页面传递到父Javascript页面,javascript,parent-child,data-transfer,Javascript,Parent Child,Data Transfer,我正在使用Javascript。我使用警报从用户处获取密码。但是,您可能知道,该警报不会屏蔽其他“肩部冲浪”的密码。为了解决这个问题,我创建了一个页面,该页面只允许用户输入从父javascript页面打开的密码。问题是javascript不会等到用户输入密码后再执行更多javascript指令。我的问题是,如何让我的javascript在执行下一条指令之前等待接收来自用户的信息 下面的父页面是我正在使用的示例。因为我在网上看到你不能屏蔽window.prompt输入,所以决定尝试打开一个新窗口,

我正在使用Javascript。我使用警报从用户处获取密码。但是,您可能知道,该警报不会屏蔽其他“肩部冲浪”的密码。为了解决这个问题,我创建了一个页面,该页面只允许用户输入从父javascript页面打开的密码。问题是javascript不会等到用户输入密码后再执行更多javascript指令。我的问题是,如何让我的javascript在执行下一条指令之前等待接收来自用户的信息

下面的父页面是我正在使用的示例。因为我在网上看到你不能屏蔽window.prompt输入,所以决定尝试打开一个新窗口,让用户将其输入到html表单中。这是对父级的最低要求(真正的父级页面要长得多,与问题无关)。 父页面:

<html>
    <head>
    <script language="javascript">
        function start()
        {
            document.write("here");
            var w = window.open('password.html','newWindow','width=550,height=170,left=150,top=200,toolbar=no,resizable=false');
            var password = "holder value";

document.write(password);
        }
    </script>
        <title>
            Parent Window
        </title>
    </head>
    <body onload="start()">
    </body>
</html>

函数start()
{
文件。填写(“此处”);
var w=window.open('password.html','newWindow','width=550,height=170,left=150,top=200,toolbar=no,resizeable=false');
var password=“持有者值”;
文件。写入(密码);
}
父窗口
子页面:

<html>  
    <head>
        <title>This is for the user to input their password</title>
        <script language="javascript">
            function Parent()
            {
console.log("working");
                //opener.document.form.parent_name.value =  document.frm.child_name.value;
//              opener.document.form.parent_name.value = document.Input.pwd.value;
                opener.document.password= document.Input.pwd.value;
                self.close();
            }
        </script>
    </head>

    <body>
        <form name="Input" method="post" action="">
            <input type="password" name="pwd">
            <input type="button" value="Submit" onClick="Parent()">     
        </form>
    </body>
</html>

这是供用户输入其密码
函数父函数()
{
控制台日志(“工作”);
//opener.document.form.parent\u name.value=document.frm.child\u name.value;
//opener.document.form.parent_name.value=document.Input.pwd.value;
opener.document.password=document.Input.pwd.value;
self.close();
}

在谷歌上搜索“HTML表单”。
尝试在子页面上设置cookie,然后在父页面上加载它