| <script type="text/javascript"> |
| function SetSrc(src) { |
| var plugin = document.getElementById('plugin'); |
| plugin.src = src; |
| } |
| function SetSize(w, h) { |
| var plugin = document.getElementById('plugin'); |
| plugin.width = w; |
| plugin.height = h; |
| } |
| function PostMessage(data, shouldTargetIframe) { |
| plugin = document.getElementById('plugin'); |
| // TODO(fsamuel): contentWindow can be accessed directly once |
| // http://wkbug.com/85679 lands. |
| if (shouldTargetIframe) { |
| plugin.contentWindow.frames[0].postMessage('testing123', '*'); |
| } else { |
| plugin.contentWindow.frames.postMessage('testing123', '*'); |
| } |
| } |
| function SetTitle(str) { |
| document.title = str; |
| } |
| document.title = 'embedder'; |
| </script> |
| |
| <object id="plugin" |
| tabindex="0" |
| type="application/browser-plugin" |
| width="640" |
| height="480" |
| border="0px"></object> |
| <script type="text/javascript"> |
| var msg; |
| function receiveMessage(event) { |
| msg = event.data; |
| if (msg == 'ready') { |
| document.title = 'ready'; |
| return; |
| } |
| if (msg.indexOf('stop_ack') == -1) { |
| event.source.postMessage('stop', '*'); |
| } else { |
| var name = msg.replace("stop_ack", "").trim(); |
| if (name !== '') { |
| window.document.title = name; |
| } else { |
| window.document.title = 'main guest'; |
| } |
| } |
| } |
| |
| var plugin = document.getElementById('plugin'); |
| window.addEventListener('message', receiveMessage, false); |
| plugin.addEventListener('-internal-instanceid-allocated', function(e) { |
| var detail = e.detail ? JSON.parse(e.detail) : {}; |
| plugin['-internal-attach'](detail.windowId, {}); |
| }); |
| </script> |