44 lines
1004 B
HTML
44 lines
1004 B
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
|
|
</head>
|
|
<body>
|
|
<iframe id="padembed" width="640" height="360" name="iframename" src="https://pad.ma/AGR/editor/00:04:55.800,00:00:21.880,00:04:55.800#embed" frameborder="0" allowfullscreen></iframe>
|
|
<script>
|
|
console.log('hello');
|
|
const $iframe = document.getElementById('padembed');
|
|
|
|
|
|
window.addEventListener('message', listener, false);
|
|
|
|
function listener(event) {
|
|
const data = JSON.parse(event.data);
|
|
if (data.event === 'init') document.getElementById(data.target).isInit = true;
|
|
console.log('received event', event);
|
|
console.log('name', event.data.name);
|
|
}
|
|
|
|
$iframe.addEventListener('load', () => {
|
|
console.log('iframe loaded');
|
|
let timeout;
|
|
function init() {
|
|
console.log('init called');
|
|
if ($iframe.isInit) {
|
|
clearTimeout(timeout);
|
|
return;
|
|
}
|
|
$iframe.contentWindow.postMessage(JSON.stringify({
|
|
data: {
|
|
oxid: 'padembed'
|
|
},
|
|
event: 'init'
|
|
}), '*');
|
|
timeout = setTimeout(init, 250);
|
|
}
|
|
init();
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |