
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
What are the MessageChannel and MessagePort Objects in HTML5?
While creating messageChannel, it internally creates two ports to send the data and forwarded it to another browsing context.
- postMessage() − Post the message throw channel
- start() − It sends the data
- close() − it closes the ports
In this scenario, we are sending the data from one iframe to another iframe. Here we are invoking the data in function and passing the data to DOM.
Example
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);
- Related Articles
- Difference between MessageChannel and WebSockets in HTML5
- How to store objects in HTML5 localStorage?
- What are save and restore methods in HTML5 Canvas?
- What are Character Entities in HTML5
- What are input elements in HTML5
- What are objects in C#?
- What are Screen objects in javascript?
- What are luminous objects?
- What are Opaque objects?
- What are illuminating objects ?
- What are the differences between Java classes and Java objects?
- What are the examples of transparent, translucent and opaque objects?
- What are free libraries for Canvas in HTML5?
- Apply gravity between two or more objects in HTML5 Canvas
- What are the differences between JavaScript Primitive Data Types and Objects?

Advertisements