1

I have a page where a user can click on a button that opens a new window using Javascript's window.open. The new "pop-up" window allows users to perform various editing actions. After processing is completed in the new window, I want to be able to return to the original page, passing the status of the completed process back, via the query string. Unfortunately, the new window stays open (in it's smaller size), with the original page visible behind it. I am trying to simply return back to the original calling page, whilst the new window closes. I believe the answer to this question must be in the way that the window.open is used in the first place. If the window was NOT opened in a new tab, and instead was "in-place", then I believe this would work as I want it to.

Snippets of the code are as follows:

I. HTML on original page:

<input type="button"  style="cursor: hand; color: #000000; font-size: 9px; font-style: bold" name="edittransaction" id="edittransaction" value="Edit Transaction" onclick="EditTransaction(this.form);">&nbsp;

II. Javascript on original page:

function EditTransaction(f) {
            
    var edit_option = '<%=EditOption%>';
    var orderid_values = document.getElementsByName('OrderIDValues');
    var orderid_value = '';
            
        for(var i = 0; i < orderid_values.length; i++){
            if(orderid_values[i].checked){
            orderid_value = orderid_values[i].value;
            }
        }

        if (orderid_value != undefined && orderid_value != null)
        {

            window.open("/memberlogin/orders/edittransaction.asp?cert=<%=sCertificate%>&loginid=<%=iSessID%>&cid=<%=iCustomerID%>&editoption=<%=EditOption%>&transactionid=" + orderid_value ,"dialogEditTransaction","resizable=0,scrollbars=yes,location=yes,toolbar=no,status=no,top=600,left=400,width=800,height=800");

        } else {
            
           alert("Please select a transaction.");           
        }
        
} // End of EditTransaction() function

III. VBscript code on the opened page (in a window), which occurs after processing is complete:

FinalStatusURL = "/memberlogin/orders/transactionhistory.asp" & "?cert=" & sCertificate & "&loginid=" & iSessID & "&cid=" & iCustomerID & "&trxid=" & iTrxID & "&finalstatus=" & finalstatuscode

Response.Redirect(FinalStatusURL)
Response.End

Please note that the new window does not necessary need to be a pop-up window. It can be full sized. Please let me know what I need to do, in order to simply close the pop-up window upon a redirect back to the original page. Thank you very much!

  • It doesn't seem that this is going to work (and there are no answers), so I will revert to a different design, and will post my answer within the next 3-days. Thank you all very much! – Bjorgen Eatinger May 03 '21 at 05:18
  • 1
    It looks like you are redirecting to a new page rather than closing the page. If you want to close the page, use window.close in JavaScript. – Dijkgraaf May 03 '21 at 23:33
  • 1
    To pass the results back to the parent, you can also refer to parent window with JavaScript and update it's URL before you close. – Dijkgraaf May 04 '21 at 00:21
  • 1
    See https://stackoverflow.com/questions/23306882/javascript-close-current-window – Dijkgraaf May 04 '21 at 00:23
  • @Dijkgraaf thank you for your input. Yes, when I first open the new page, it is for the purpose of editing a transaction which is selected on the original page. The new page is all ASP code. However, I tried using window.location.replace, instead of ASP's Response.Redirect, and the result was the same. I was still in the newly opened pop-up window, instead of being taken back to the original page. I believe the solution is in the way that the NEW window is opened. That is, the original should be closed, when the new window is opened. But I don't know how to do that. – Bjorgen Eatinger May 04 '21 at 02:31
  • 1
    You need to reference parent.window.location.replace – Dijkgraaf May 04 '21 at 03:56
  • @Dijkgraaf, thank you for your comment. It tried to use parent.window.location.replace, in the OPENED window, to return back to the calling window, but the same behavior is exhibited (i.e., the new window stays open, with the original page in view. The only code that works is using "_self", in the window.open command. I will document as an answer shortly. – Bjorgen Eatinger May 04 '21 at 16:26

0 Answers0