Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: ppapi/examples/scripting/post_message.html

Issue 6716005: A proposal and implementation for an initial postMessage interface. These in... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright (c) 2011 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
7 -->
8 <head>
9 <title>postMessage Example</title>
10 </head>
11
12 <body>
13
14 <script type="text/javascript">
15
16 function SendString() {
17 plugin = document.getElementById('plugin');
18
19 // If we haven't already done it, set up an 'onmessage' function. This will
20 // get invoked whenever the plugin calls Instance::PostMessage in C++ (or
21 // PPB_Messaging::PostMessage in C). In this case, we're expecting a bool to
22 // tell us whether the string we passed was a palindrome.
23 if (!plugin.onmessage) {
24 plugin.onmessage = function(message_event) {
25 if (message_event.data) {
26 alert("The string was a palindrome.");
27 } else {
28 alert("The string was not a palindrome.");
29 }
30 }
31 }
32
33 var inputBox = document.getElementById("inputBox");
34
35 // Send the string to the plugin using postMessage. This results in a call
36 // to Instance::HandleMessage in C++ (or PPP_Messaging::HandleMessage in C).
37 plugin.postMessage(inputBox.value);
38 }
39
40 </script>
41
42 <input type="text" id="inputBox" name="inputBox" value="ablewasiereisawelba"/>
43 <p>
44 <button onclick='SendString()'>Is Palindrome</button>
45 <object id="plugin" type="application/x-ppapi-post-message-example"
46 width="0" height="0"/>
47 <hr>
48 </body>
49 </html>
50
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698