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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/examples/scripting/post_message.html
===================================================================
--- ppapi/examples/scripting/post_message.html (revision 0)
+++ ppapi/examples/scripting/post_message.html (revision 0)
@@ -0,0 +1,37 @@
+<body>
+
+<script type="text/javascript">
+
+function SendString() {
+ plugin = document.getElementById('plugin');
+
+ // If we haven't already done it, set up an 'onmessage' function. This will
+ // get invoked whenever the plugin calls Instance::PostMessage in C++ (or
+ // PPB_Instance::PostMessage in C). In this case, we're expecting a bool to
+ // tell us whether the string we passed was a palindrome.
+ if (!plugin.onmessage) {
+ plugin.onmessage = function(message_event) {
+ if (message_event.data) {
+ alert("The string was a palindrome.");
+ } else {
+ alert("The string was not a palindrome.");
+ }
+ }
+ }
+
+ var inputBox = document.getElementById("inputBox");
+
+ // Send the string to the plugin using postMessage. This results in a call
+ // to Instance::HandleMessage in C++ (or PPP_Instance::HandleMessage in C).
+ plugin.postMessage(inputBox.value);
+}
+
+</script>
+
+<input type="text" id="inputBox" name="inputBox" value="ablewasiereisawelba"/>
+<p>
+<button onclick='SendString()'>Is Palindrome</button>
+<object id="plugin" type="application/x-ppapi-post-message-example"
+ width="0" height="0"/>
+<hr>
+</body>
Property changes on: ppapi/examples/scripting/post_message.html
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698