W3C home > Mailing lists > Public > public-html-diffs@w3.org > July 2008

spec/Overview.html 1.1065 1876 Correct example for postMessage(). (cred

From: poot <cvsmail@w3.org>
Date: Tue, 15 Jul 2008 20:04:44 +0900 (JST)
To: public-html-diffs@w3.org
Message-Id: <20080715110444.85BDB2BBF1@toro.w3.mag.keio.ac.jp>

Correct example for postMessage(). (credit: avk) (whatwg r1876) (changed
by: Ian Hickson)

Diffs for this change per section: 
  7.4.1 Introduction

Current content per affected section: 

Previously published WD content per affected section: 

Cumulative diff: http://people.w3.org/mike/diffs/html5/spec/Overview.diff.html



RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.1064
retrieving revision 1.1065
diff -u -d -r1.1064 -r1.1065
--- Overview.html	15 Jul 2008 10:40:36 -0000	1.1064
+++ Overview.html	15 Jul 2008 10:45:45 -0000	1.1065
@@ -42290,20 +42290,22 @@
   <div class=example>
    <p>For example, if document A contains an <code><a
-    href="#object">object</a></code> element that contains document B, and
+    href="#iframe">iframe</a></code> element that contains document B, and
     script in document A calls <code title=dom-window-postMessage-2><a
-    href="#postmessage">postMessage()</a></code> on document B, then a
-    message event will be fired on that element, marked as originating from
-    document A. The script in document A might look like:</p>
+    href="#postmessage">postMessage()</a></code> on the <code><a
+    href="#window">Window</a></code> object of document B, then a message
+    event will be fired on that object, marked as originating from the
+    <code><a href="#window">Window</a></code> of document A. The script in
+    document A might look like:</p>
-   <pre>var o = document.getElementsByTagName('object')[0];
+   <pre>var o = document.getElementsByTagName('iframe')[0];
 o.contentWindow.postMessage('Hello world', 'http://b.example.org/');</pre>
    <p>To register an event handler for incoming events, the script would use
     <code title="">addEventListener()</code> (or similar mechanisms). For
     example, the script in document B might look like:</p>
-   <pre>document.addEventListener('message', receiver, false);
+   <pre>window.addEventListener('message', receiver, false);
 function receiver(e) {
   if (e.origin == 'http://example.com') {
     if (e.data == 'Hello world') {
Received on Tuesday, 15 July 2008 11:05:26 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:41:38 UTC