| 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 function SetTitle(str) { | 33 function SetTitle(str) { |
| 24 document.title = str; | 34 document.title = str; |
| 25 } | 35 } |
| 26 | 36 |
| 27 window.document.title = 'embedder'; | 37 window.document.title = 'embedder'; |
| 28 </script> | 38 </script> |
| 29 | 39 |
| 30 <object id="plugin" | 40 <object id="plugin" |
| 31 tabindex="0" | 41 tabindex="0" |
| 32 type="application/new-browser-plugin" | 42 type="application/new-browser-plugin" |
| 33 width="640" | 43 width="640" |
| 34 height="480" | 44 height="480" |
| 35 border="0px"></object> | 45 border="0px"></object> |
| 46 <script type="text/javascript"> |
| 47 var msg; |
| 48 function receiveMessage(event) { |
| 49 msg = event.data; |
| 50 if (msg == 'ready') { |
| 51 document.title = 'ready'; |
| 52 return; |
| 53 } |
| 54 if (msg.indexOf('stop_ack') == -1) { |
| 55 event.source.postMessage('stop', '*'); |
| 56 } else { |
| 57 var name = msg.replace("stop_ack", "").trim(); |
| 58 if (name !== '') { |
| 59 window.document.title = name; |
| 60 } else { |
| 61 window.document.title = 'main guest'; |
| 62 } |
| 63 } |
| 64 } |
| 65 document.getElementById('plugin').addEventListener('message', receiveMessage, fa
lse); |
| 66 </script> |
| OLD | NEW |