1 <!DOCTYPE html> 2 <html> 3 <!-- 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. 7 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 10 it on the page. 11 --> 12 <head> 13 <title>URLLoader Example</title> 14 </head> 15 16 <body> 17 <script> 18 19 function StartRequest() { 20 var plugin = document.getElementById("plugin"); 21 var inputBox = document.getElementById("inputBox"); 22 plugin.postMessage("go"); 23 } 24 25 </script> 26 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> 29 30 <button onclick="StartRequest()">Start request</button> 31 <object id="plugin" type="application/x-ppapi-url-loader-example" 32 width="1" height="1"> 33 </object> 34 <hr> 35 <div id="log_result" style="background-color:#EEE; border:1px solid black;"> 36 <i>Result will go here...</i> 37 </div> 38 39 <script> 40 41 function HandleMessage(message_event) { 42 document.getElementById("log_result").innerHTML = message_event.data; 43 } 44 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); 49 50 </script> 51 </body> 52 </html> 53 54