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 14: Line 14:


   <script type="application/javascript">
   <script type="application/javascript">
     document.querySelector("iframe").addEventListener( "load", function(e) {
     window.onload = function() {
      debugger;
       var iframeWin = document.getElementById("iframeWin");
       var iframeWin = document.getElementById("iframeWin");
      // Set iframe height
      iframeWin.height = iframe.contentWindow.document.body.scrollHeight;
       var content = (iframeWin.contentWindow || iframeWin.contentDocument);
       var content = (iframeWin.contentWindow || iframeWin.contentDocument);
       if (content.document)content = content.document;
       if (content.document)content = content.document;
Line 29: Line 30:
       // Show iframe
       // Show iframe
       iframeWin.style.display="block";
       iframeWin.style.display="block";
    });
    window.onload = function() {
      var iframe = document.getElementById("iframeWin");
      iframe.height = iframe.contentWindow.document.body.scrollHeight;
     }
     }
    document.querySelector("iframe").addEventListener("click", function(e){
      debugger;
      console.log("here");
      setTimeout(myGreeting, 50000);
      var iframeWin = document.getElementById("iframeWin");
      iframeWin.contentWindow.postMessage(null, 'https://your-second-site.example');
    });
    window.addEventListener('message', event => {
      debugger;
      console.log("no here");
      setTimeout(myGreeting, 50000);
      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 15:31, 7 July 2023

Usage