Web messaging is a way for documents in separate browsing contexts to share data without the DOM being exposed to malicious cross-origin scripting.Unlike other forms of cross-site communication (cross-domain XMLHttp Request, or dynamic script insertion), web messaging never directly exposes the DOM.

borjac datingbuzz message send site-49borjac datingbuzz message send site-39borjac datingbuzz message send site-86

Cross-document messaging is often referred to by its syntax as .

Along with server-sent events and web sockets, cross-document and channel messaging are a valuable part of the HTML5 “suite” of communication interfaces.

Web messaging is supported by Opera, Chrome, and Safari, though Safari ≤ 5.1.2 contains a bug.

Internet Explorer 8+ partially supports cross-document messaging: it currently works with iframes, but not new windows.

iframe.content Message('The message to send.','https://dev.opera.com'); } Event Listener('click',click Handler,false); var message Event Handler = function(event){ // check that the origin is one we want.

if(event.origin == 'https://dev.opera.com'){ alert(event.data); } } Event Listener('message', message Event Handler,false); is being invoked inside an event handler that requires user interaction. A better way to handle this in the real world, however, is to ensure that scripts in the target browsing context have had time to set up listeners and that they are ready to receive our messages.

To check that, we can send a event to our parent document when the new document is loaded. In this example, we are going to open a new window.

Internet Explorer 10, however, will support interface and shares its properties.

Message events however do not bubble, are not cancelable, and have no default action.

Now we’ve looked at Message events, let’s continue by getting to grips with cross-document messaging.

To send a cross-document message, we need to create a new browsing context — either by creating a new window or referencing an var iframe = document.query Selector('iframe'); var button = document.query Selector('button'); var click Handler = function(){ // iframe.content Window refers to the iframe’s window object.