
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to send a cross-document message with HTML?
Create a new web browsing context either by creating new iframe or new window. We can send the data using with postMessage() and it has two arguments. They are as
- message − The message to send
- targetOrigin − Origin name
Let us see an example to send a message from iframe to button:
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);
- Related Articles
- How to send message from firebase console after creation project?
- How to create a link to send email with a subject in HTML?
- How to create a valid HTML document with no element?
- How to create a valid HTML document with no and element?
- How to create a link to send email in HTML?
- HTML5 Cross Browser iframe post message - child to parent?
- How to send a html based email using a JSP page?
- How to send HTML email using Android App?
- How to create an HTML Document?
- How to create a section in a document in HTML?
- How to create a chat message with CSS?
- How to create a message box with Tkinter?
- How to include Modernizr in HTML document?
- Create HTML Document with Custom URL for the document in JavaScript
- How to create a hyperlink to link another document in HTML?

Advertisements