Chromium Code Reviews| 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,50 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <!-- |
| + Copyright (c) 2011 The Native Client Authors. All rights reserved. |
|
neb
2011/03/23 17:45:30
Chromium Authors?
dmichael(do not use this one)
2011/03/23 18:48:04
Done.
|
| + Use of this source code is governed by a BSD-style license that can be |
| + found in the LICENSE file. |
| + --> |
| +<head> |
| + <title>postMessage Example</title> |
| +</head> |
| + |
| +<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_Messaging::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_Messaging::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> |
| +</html> |
| + |
| Property changes on: ppapi/examples/scripting/post_message.html |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |