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

时间:2021-09-11 13:17:02   收藏:0   阅读:32

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>

原文:https://www.cnblogs.com/aisowe/p/15250129.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!