OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <body> |
| 3 <object id="plugin" |
| 4 type="application/browser-plugin" |
| 5 width="640" |
| 6 height="480"></object> |
| 7 <script> |
| 8 var loadstop = false; |
| 9 var requestCommChannel = false; |
| 10 function SetSrc(src) { |
| 11 var plugin = document.getElementById('plugin'); |
| 12 plugin.src = src; |
| 13 } |
| 14 // Open a two-way communication channel with the guest. |
| 15 function OpenCommChannel() { |
| 16 if (!loadstop) { |
| 17 requestCommChannel = true; |
| 18 return; |
| 19 } |
| 20 var plugin = document.getElementById('plugin'); |
| 21 plugin.contentWindow.frames.postMessage('test', '*'); |
| 22 } |
| 23 |
| 24 // Establish a two-way channel with the guest. |
| 25 window.addEventListener('message', function(e) { |
| 26 document.title = event.data; |
| 27 }); |
| 28 var plugin = document.getElementById('plugin'); |
| 29 plugin.addEventListener('-internal-loadstop', function(e) { |
| 30 loadstop = true; |
| 31 if (requestCommChannel) { |
| 32 plugin.contentWindow.frames.postMessage('test', '*'); |
| 33 } |
| 34 }); |
| 35 </script> |
| 36 </body> |
| 37 </html> |
OLD | NEW |