Monday, December 5th, 2005
Cross-document messaging: An answer to the cross domain debate?
<p>Arve Bersvendsen, of Opera, has written about Cross document messaging, including examples to test it out in the Opera browser.
What is Cross-document messaging
Cross-document messaging is a little talked off HTML5/Web Applications 1.0 feature that the WhatWG has been specifying
How does it work?
You have senders and receivers:
Sender
function sendMessage(val){
var receiver = document.getElementsByTagName("iframe")[0].contentDocument;
receiver.postMessage(val);
}
Receiver
document.addEventListener('message',function(ev){
var output = document.getElementsByTagName("textarea")[0];
output.value += "Message from domain "
+ev.domain+" and URI "+ev.uri+":n";
output.value += ev.data+"nn";
parent = ev.source;
var d = new Date();
ev.source.postMessage("The document at "
+location.href+" received your message at "+d);
setTimeout(delayedResponse,2500,ev.source);
}, false);
Related Content:











xdghdyjcyjdgynv g h fghfghfg dyh tduygh