获取在父窗口“联系”用 window.open 打开的子窗口

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <button onclick="clickHandler()">打开窗口</button>
    <script>
      function clickHandler() {
        const targetWindow = window.open("./sub.html");
        targetWindow.leitang = 1;
        alert(targetWindow.opener === window);
      }
    </script>
  </body>
</html>

获取在父窗口“联系”用 window.open 打开的子窗口

上一篇:midway日志体系


下一篇:Project 'com.cooldatasoft:spring-boot-starter-parent:2.3.10.RELEASE' not found