locked
Default window not closing in Edge or Chrome RRS feed

  • Question

  • User1016820894 posted

    I have a default.aspx page that opens another page in a pop-up window. Once it does that it is supposed to close the default window using self.close. It works fine in IE but in Edge and Chrome it never closes. I need a solution that will work in all 3 browsers. Thanks!

    Here is my code:

        <script type="text/javascript">
            function InvokeWindow1() {
                   var heightnum = screen.height - 100;
                   var widthnum = screen.width - 100;
                   var leftpos = screen.width / 2 - 1500 / 2;
                   var toppos = screen.height / 2 - 800 / 2;
                   window.open("mainpage.aspx", "_blank", "width=" + widthnum + ",height=" + heightnum +",top=20,left=20,location = 0,resizable=0,scrollbars=1,toolbar=0,menubar=0,status=0,titlebar=0");
                   window.open('', '_self', '');
                   self.close();
               } 
        </script>

    Monday, April 13, 2020 1:18 PM

Answers

  • User-18289217 posted
    That is a security feature. However you may want to try the following:

    window.open(location, '_self').close();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 13, 2020 1:43 PM