ASDSO Dam Safety Toolbox

Template: WhatLinksHere: Difference between revisions

From ASDSO Dam Safety Toolbox
Jump to: navigation, search
No edit summary
No edit summary
Line 37: Line 37:


     document.querySelector("iframe").addEventListener("click", function(e){
     document.querySelector("iframe").addEventListener("click", function(e){
       console.log(window.top.location.href);
       var iframeWin = document.getElementById("iframeWin");
      iframeWin.contentWindow.postMessage(null, 'https://your-second-site.example');
    });


      //window.top.location.href = "http://www.example.com";
    window.addEventListener('message', event => {
      console.log(event);
      console.log(event.origin);


      // IMPORTANT: check the origin of the data!
      if (event.origin === 'https://your-first-site.example') {
          // The data was sent from your site.
          // Data sent with postMessage is stored in event.data:
          console.log(event.data);
      } else {
          // The data was NOT sent from your site!
          // Be careful! Do not use it. This else branch is
          // here just for clarity, you usually shouldn't need it.
          return;
      }
     });
     });
   </script>
   </script>
</html>
</html>

Revision as of 14:03, 7 July 2023

Usage