blob: 021fffab68f5ae9fe2f72a6c3c0bf60a14b333c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<!DOCTYPE html>
<title>Helper IFrame</title>
<script>
'use strict';
async function onLoad() {
// Load the innermost child iframe and its content.
const params = new URLSearchParams(self.location.search);
const frame = document.createElement('iframe');
frame.src = params.get('target');
document.body.appendChild(frame);
self.addEventListener('message', evt => {
// Pass any operations request messages to the
// innermost child iframe.
if (evt.data.op){
// Ensure that the iframe has loaded before passing
// on the message.
frame.addEventListener('load', function(){
frame.contentWindow.postMessage(evt.data, '*');
});
}
else {
// All other messages, should be sent back to the
// top-level site.
if (self.opener)
self.opener.postMessage(evt.data, '*');
else
self.top.postMessage(evt.data, '*');
}
});
}
self.addEventListener('load', onLoad);
</script>
|