new_tab_then_close.html 359 B

12345678910111213141516
  1. <html>
  2. <script>
  3. var openedWindow = null;
  4. function openNewWindowOrClose() {
  5. if (openedWindow == null) {
  6. openedWindow = window.open('about:blank', '');
  7. } else {
  8. openedWindow.close();
  9. openedWindow = null;
  10. }
  11. }
  12. </script>
  13. <body onclick="openNewWindowOrClose();">
  14. <p>some content</p>
  15. </body>
  16. </html>