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.
8 This example just uses postMessage to tell the plugin to fetch a file.
9 The plugin will echo the contents of that file back to us and we'll display
13 <title>URLLoader Example
</title>
19 function StartRequest() {
20 var plugin
= document
.getElementById("plugin");
21 var inputBox
= document
.getElementById("inputBox");
22 plugin
.postMessage("go");
27 <p>This test must be run over HTTP. If you're a Chrome developer, see the
28 README_chrome_developer.txt in this directory for how to run.
</p>
30 <button onclick=
"StartRequest()">Start request
</button>
31 <object id=
"plugin" type=
"application/x-ppapi-url-loader-example"
35 <div id=
"log_result" style=
"background-color:#EEE; border:1px solid black;">
36 <i>Result will go here...
</i>
41 function HandleMessage(message_event
) {
42 document
.getElementById("log_result").textContent
= message_event
.data
;
45 // Attach a listener for the message event. This must happen after the plugin
46 // object was created.
47 var plugin
= document
.getElementById("plugin");
48 plugin
.addEventListener("message", HandleMessage
, false);