Use event source to call postMessage - Javascript DOM

Javascript examples for DOM:Event

Description

Use event source to call postMessage

Demo Code

ResultView the demo in separate window

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
   <head> 
      <meta charset="utf-8"> 
   </head> 
   <body> 
      <iframe src="http://your server html"></iframe> 
      <script>
        var token = "abc";
        window.addEventListener("message", receiveMessage, false);
        function receiveMessage(event) {
            if (event.data === "accquireToken")
                event.source.postMessage(token,"*");
        }//from  ww  w.  j a  va 2  s.  c o  m
    
      </script>  
   </body>
</html>

Related Tutorials