我正在尝试检查是否打开了上一个窗口,然后每次关闭并打开新窗口

时间:2019-04-01 09:42:02

标签: javascript

使用window.open方法(如果已打开)关闭该窗口并每次通过关闭前一个窗口来打开新窗口。

<script type="text/javascript">



        function PrintGPass(content) {
            var leftPosition, topPosition, width, height;

            width = 800;
            height = 600;

            //Allow for borders.
            leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
            //Allow for title and status bars.
            topPosition = (window.screen.height / 2) - ((height / 2) + 50);
            //Open the window. 

            //    var h = "<html><head></head><body ><h4a>Visitor Pass</h4a><p><h9>This is a variable I want to print to the printer with the browser!</h9></p></body></html>" 

            //        $('.printable').html(h);



            var printWindow = window.open('', "Attachment", 'height=' + height + ',width=' + width + 'left=' + leftPosition + ',top=' + topPosition + ',screenX=' + leftPosition + ',screenY=' + topPosition);
            //        window.open('', "Print-Window", "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");

            //printWindow.document.write(content);
            printWindow.document.write(content);
            //document.getElementById("Image1");
            //       printWindow.document.close();

            //       printWindow.print();

            //        printWindow.close();

        }
    </script>

0 个答案:

没有答案