OLD | NEW |
1 <script type="text/javascript"> | 1 <script type="text/javascript"> |
2 function SetSrc(src) { | 2 function SetSrc(src) { |
3 var plugin = document.getElementById('plugin'); | 3 var plugin = document.getElementById('plugin'); |
4 plugin.src = src; | 4 plugin.src = src; |
5 } | 5 } |
6 function SetSize(w, h) { | 6 function SetSize(w, h) { |
7 var plugin = document.getElementById('plugin'); | 7 var plugin = document.getElementById('plugin'); |
8 plugin.width = w; | 8 plugin.width = w; |
9 plugin.height = h; | 9 plugin.height = h; |
10 } | 10 } |
| 11 function PostMessage(data, targetiframe) { |
| 12 plugin = document.getElementById('plugin'); |
| 13 // TODO(fsamuel): contentWindow can be accessed directly once |
| 14 // http://wkbug.com/85679 lands. |
| 15 if (targetiframe) { |
| 16 plugin.contentWindow.frames[0].postMessage('testing123', '*'); |
| 17 } else { |
| 18 plugin.contentWindow.frames.postMessage('testing123', '*'); |
| 19 } |
| 20 } |
11 function Back() { | 21 function Back() { |
12 var plugin = document.getElementById('plugin'); | 22 var plugin = document.getElementById('plugin'); |
13 plugin.back(); | 23 plugin.back(); |
14 } | 24 } |
15 function Forward() { | 25 function Forward() { |
16 var plugin = document.getElementById('plugin'); | 26 var plugin = document.getElementById('plugin'); |
17 plugin.forward(); | 27 plugin.forward(); |
18 } | 28 } |
19 function Go(relativeIndex) { | 29 function Go(relativeIndex) { |
20 var plugin = document.getElementById('plugin'); | 30 var plugin = document.getElementById('plugin'); |
21 plugin.go(relativeIndex); | 31 plugin.go(relativeIndex); |
22 } | 32 } |
23 </script> | 33 </script> |
24 | 34 |
25 <object id="plugin" | 35 <object id="plugin" |
26 tabindex="0" | 36 tabindex="0" |
27 type="application/new-browser-plugin" | 37 type="application/new-browser-plugin" |
28 width="640" | 38 width="640" |
29 height="480" | 39 height="480" |
30 border="0px"></object> | 40 border="0px"></object> |
| 41 <script type="text/javascript"> |
| 42 var msg; |
| 43 function receiveMessage(event) { |
| 44 msg = event.data; |
| 45 if (msg == 'ready') { |
| 46 document.title = 'ready'; |
| 47 return; |
| 48 } |
| 49 if (msg.indexOf('stop_ack') == -1) { |
| 50 event.source.postMessage('stop', '*'); |
| 51 } else { |
| 52 var name = msg.replace("stop_ack", "").trim(); |
| 53 if (name !== '') { |
| 54 window.document.title = name; |
| 55 } else { |
| 56 window.document.title = 'main guest'; |
| 57 } |
| 58 } |
| 59 } |
| 60 document.getElementById('plugin').addEventListener('message', receiveMessage, fa
lse); |
| 61 </script> |
OLD | NEW |