Mr. Engineer
Mr. Engineer

Reputation: 11

Window.open() forgets previous window name after reload/postback

I have a workflow that at the end of postback has to open a popup window. Now most browsers block popups not originating from a user event, so we did the following:

  1. Upon the user click open the popup to avoid blockage, it opens up with a plain loading screen. We named the window "X"
  2. The background page posts back
  3. At the returned response, it finalizes the request parameters and makes a hidden form to be submitted, with window target as "X".

This has been working fine for us, until recently where a specific user is getting a problem. The JavaScript at the time of response does not find any existing "X" window and thus, opens a new one. So we end up with two popups, one being the actual workflow and other the placeholder loading screen. I have tried to identify any chrome setting but I could not find any. P.s. same computer works fine with edge. Any ideas?

Simplified Code of what we are doing;

<script>
    form1 = document.getElementById("form1");
    form2 = document.getElementById("form2");
    $(document).ready(function() {
        if(canProceed) { //will be false when the page first opened, set from sever side
            window.open('', "X", "top=0,left=0,status=1,toolbar=0,resizable=1,scrollbars=1");       //second window.open() call
            form2.setAttribute("target", "X");
            form2.submit();
        }
    });

    function beginSequence() // called upon a user click
    {
        window.open('localhost/placeholderloadingscreen', "X", "top=0,left=0,status=1,toolbar=0,resizable=1,scrollbars=1");         //first window.open() call
        form1.submit(); //causes the page to postback so I cant capture the variable from previous line
    }

</script>

Upvotes: 0

Views: 38

Answers (0)

Related Questions