Popup browser back to parent browser after a certain page is reached

非 Y 不嫁゛ 提交于 2019-12-23 13:04:43

问题


I have a popup (which I used by necessity) that is opened on a link click. I have the user going through a series of pages picking attributes to then be sent to a shopping cart.

My problem: After the user reaches the end of the selection process i want to kill the open popup and send the request back to the original browser (parent) so the user can checkout.

Any idea how I would do this?


回答1:


Javascript: in the child (popup) window.

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

Is that what your looking for?




回答2:


The parent window can be accessed using "opener" in JavaScript. Example:

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

or

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



回答3:


Script in my child form:

<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>

Script in my parent form:

<% @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>

This is work but not as i want, any one if found good solution please suggest.



来源:https://stackoverflow.com/questions/613079/popup-browser-back-to-parent-browser-after-a-certain-page-is-reached

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!