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

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

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (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 <body>
2
3 <script type="text/javascript">
4
5 function SendString() {
6 plugin = document.getElementById('plugin');
7
8 // If we haven't already done it, set up an 'onmessage' function. This will
9 // get invoked whenever the plugin calls Instance::PostMessage in C++ (or
10 // PPB_Instance::PostMessage in C). In this case, we're expecting a bool to
11 // tell us whether the string we passed was a palindrome.
12 if (!plugin.onmessage) {
13 plugin.onmessage = function(message_event) {
14 if (message_event.data) {
15 alert("The string was a palindrome.");
16 } else {
17 alert("The string was not a palindrome.");
18 }
19 }
20 }
21
22 var inputBox = document.getElementById("inputBox");
23
24 // Send the string to the plugin using postMessage. This results in a call
25 // to Instance::HandleMessage in C++ (or PPP_Instance::HandleMessage in C).
26 plugin.postMessage(inputBox.value);
27 }
28
29 </script>
30
31 <input type="text" id="inputBox" name="inputBox" value="ablewasiereisawelba"/>
32 <p>
33 <button onclick='SendString()'>Is Palindrome</button>
34 <object id="plugin" type="application/x-ppapi-post-message-example"
35 width="0" height="0"/>
36 <hr>
37 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698