我有一个弹出窗口(我必须使用它)在链接点击时打开。我让用户通过一系列页面选择属性然后发送到购物车。

我的问题:在用户到达选择过程结束后,我想杀死打开的弹出窗口并将请求发送回原始浏览器(父级),以便用户可以结帐。

知道我会怎么做吗?

有帮助吗?

解决方案

Javascript:在子(弹出窗口)窗口中。

window.opener.location = 'page.html";
window.close();

这是你想要的吗?

其他提示

可以使用“开启者”访问父窗口。在JavaScript中。 例如:

window.opener.title='hello parent window';

window.opener.location.href='http://redirect.address';

我的孩子形式的脚本:

<script language="JavaScript" type="text/javascript">
    function SetData() {
        // form validation
         // var frmvalidator  = new Validator("myForm");
        // frmvalidator.addValidation("name","req","Please enter Account Name");

        // get the new dialog values
        var str1 = document.getElementById("name").value;
        var winArgs = str1;

        // pass the values back as arguments
        window.returnValue = winArgs;
        window.close();
        document.myForm.submit();
    }
</script>

我的父母表格中的脚本:

<% @account_head= current_company.account_heads.find_by_name("Sundry Debtors")%>
<script type="text/javascript">
    function OpenDialog() {
        var winSettings = 'center:yes;resizable:no;help:yes;status:no;dialogWidth:450px;dialogHeight:200px';

        // return the dialog control values after passing them as a parameter
        winArgs = window.showModalDialog('<%= "/accounts/new?account_head_id=#{@account_head.id} #man" %>', winSettings);

        if(winArgs == null) {
            window.alert("no data returned!");
        } else {
            // set the values from what's returned
            document.getElementById("to_account_auto_complete").value = winArgs;
        }
    }
</script>

这是工作,但不是我想要的,任何一个如果找到好的解决方案请建议。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top