 <p>HTML5 postMessage interface is not good. I propose an intuitive one. you can download it from my site: <a href="http://www.jackiszhp.info/tech/postMSG.html" rel="nofollow">http://www.jackiszhp.info/tech/postMSG.html</a></p> <p>window.MSG.post(msgname, msgdata, arrayOfDomainTarget, arrayOfWindowIDTarget)</p> <p>this 'window' can be omit, not similar to the one specified in HTML5 there you need an window object. Here, you do not. this 'window' just indicate MSG is in the global space.</p> <p>msgname is the the name the message category. msgdata is a JSON object. it will be stringified before post arrayOfDomainTarget, arrayOfWindowIDTarget I use logical AND. originally it was OR later I changed it to AND. more appropriate. I guess. and I let "*" to be the wildcard for all windowID.</p> <p>the caller's information does not present in the parameter at all since the browser knows all the information. so we can see that this method does not allow the sender to fool the receiver.</p> <p>the sender just call as follows.</p> <pre><code>window.name="myWindowID"; MSG.post("cmd",{what:'do thing abc',parameter:'the value of a parameter'},["jackiszhp.info"],[*]); </code></pre> <p>for the receiver, 2 things.</p> <pre><code>//#1 define the message handler function messageHandler(e){ var obj=JSON.parse(e.detail); obj.name is the msgname = 'cmd' obj.data is the msgdata = {what:'fuck',who:'not to tell'}; obj.source is the sender obj.source.href is the sender's window.location.href obj.source.WID is the sender's window.name="myWindowID"; obj.target is the target of this event obj.target.domains is the target domains of this event obj.target.WIDs is the target WIDs of this event .... } //#2 register the message handler window.addEventListener(msgname, messageHandler,false); or document.addEventListener(msgname, messageHandler,false); //to respond, window.name="hereMywindowID"; MSG.post("cmd",{what:'do thing def',parameter:'the value of a parameter'},["jackiszhp.info"],['myWindowID']); //clearly, we can see that this response only the original sender can receive it. //unless in the target domain, accidently, there are two windows with same ID "myWindowID". </code></pre> <p>Additional note:</p> <h1>A. window can be uniquely identified. but here, I did not use it. I use window.name instead. about window ID, you can check this link: <a href="https://developer.mozilla.org/en-US/docs/Code_snippets/Windows#Uniquely_identifying_DOM_windows" rel="nofollow">https://developer.mozilla.org/en-US/docs/Code_snippets/Windows#Uniquely_identifying_DOM_windows</a></h1> <h1>B. I hope the mozilla can take my interface and include it into the firefox.</h1>