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.
9 <title>postMessage Example
</title>
12 function HandleMessage(message_event
) {
13 if (message_event
.data
) {
14 alert("The string was a palindrome.");
16 alert("The string was not a palindrome.");
20 function AddListener() {
21 var plugin
= document
.getElementById("plugin");
22 plugin
.addEventListener("message", HandleMessage
, false);
24 document
.addEventListener("DOMContentLoaded", AddListener
, false);
32 function SendString() {
33 var plugin
= document
.getElementById("plugin");
34 var inputBox
= document
.getElementById("inputBox");
36 // Send the string to the plugin using postMessage. This results in a call
37 // to Instance::HandleMessage in C++ (or PPP_Messaging::HandleMessage in C).
38 plugin
.postMessage(inputBox
.value
);
43 <input type=
"text" id=
"inputBox" name=
"inputBox" value=
"ablewasiereisawelba"/>
45 <button onclick=
"SendString()">Is Palindrome
</button>
46 <object id=
"plugin" type=
"application/x-ppapi-post-message-example"
47 width=
"1" height=
"1"/>