Search
 
SCRIPT & CODE EXAMPLE
 

HTML

html5 mssenger

var loadHandler = function() {
   var mc, portMessageHandler;
   mc = new MessageChannel();
   window.parent.postMessage('documentAHasLoaded','http://foo.example',[mc.port2]);
   
   portMessageHandler = function(portMsgEvent) {
      alert( portMsgEvent.data );
   }
   
   mc.port1.addEventListener('message', portMessageHandler, false);
   mc.port1.start();
}
window.addEventListener('DOMContentLoaded', loadHandler, false);
Comment

html5 mssenger

var iframe = document.querySelector('iframe');
var button = document.querySelector('button');

var clickHandler = function() {
   iframe.contentWindow.postMessage('The message to send.',
      'https://www.tutorialspoint.com);
}
button.addEventListener('click',clickHandler,false);
Comment

html5 mssenger

var messageEventHandler = function(event){
   
   // check that the origin is one we want.
   if(event.origin == 'https://www.tutorialspoint.com') {
      alert(event.data);
   }
}
window.addEventListener('message', messageEventHandler,false);
Comment

PREVIOUS NEXT
Code Example
::  
Html ::  
::  
Html :: estrutura html 
::  
::  
::  
::  
::  
::  
::  
::  
::  
::  
::  
Html ::  
Css ::  
::  
::  
:: html center video 
::  
::  
::  
:: css bottom shadow 
::  
Css ::  
::  
::  
Css :: adding shadow to a div 
::  
ADD CONTENT
Topic
Content
Source link
Name
9+9 =