Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to add event listener to iframe

var iframe = document.getElementById('myIFrame');
iframe.contentWindow.body.addEventListener('mouseup', Handler);

function Handler() {
    alert('works');
}
Comment

how to get event from iframe

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="expires" content="0">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  </head>
  <body>
    <h1>CHILD</h1>
    
    <div>
      <h3>Received data:</h3>
      <div id="placeholder"></div>
    </div>
    
    <script>
    
      /* DEFINITIONS */
      var parentWindow = window.parent;
      
      /*
      * RECEIVE MESSAGE FROM PARENT
      */

      window.addEventListener("message", (e) => {
        var data = e.data;
        console.log("RECEIVED message from PARENT TO CHILD", data);

        document.getElementById("placeholder").innerText = data;

      });
      
      /* SHAKE HAND WITH PARENT */
      window.addEventListener("load", () => {
        parentWindow.postMessage("shakehand", "*");
      });
      
    </script>
  </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript Ecrire une fonction afficherTable2() qui affiche la table de multiplication de 2 dans le contenu d’un élément p. 
Javascript :: announcement for all server bot is in 
Javascript :: js page head comment 
Javascript :: Stateless/Presentational/Dumb component 
Javascript :: route edit button in laravel ajax 
Javascript :: javascript array group duplicates 
Javascript :: not getting jsp option in sts 
Javascript :: react native return null 
Javascript :: navigate to another page on vue js button 
Javascript :: regression line 
Javascript :: ex: Javascript 
Javascript :: cy wait for xhr 
Javascript :: react get dynamic window sizes 
Javascript :: how to print date in javascript without time 
Javascript :: dom jquery 
Javascript :: After installing a basic setup using above command, install below npm packages 
Javascript :: es6-map-an-array-of-objects-to-return-an-array-of-objects-with-new-keys 
Javascript :: remove falsy values from object lodash 
Javascript :: alert message in js 
Javascript :: react history push search params 
Javascript :: xslt 2 node text replace string 
Javascript :: factorial recursion javascript 
Javascript :: script.js:15 Uncaught ReferenceError: d3 is not defined at script.js 
Javascript :: remove or add class jquery 
Javascript :: js convert urls in content to links 
Javascript :: angular resolver for cookie 
Javascript :: Detect backspace pressed eventlistener 
Javascript :: How to Subtract the numbers in the array, starting from the left in javascript 
Javascript :: nodejs read file sent in the request without saving to file system 
Javascript :: sequlize where clause involving associated relationship 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =