example-index.html
| 1 |
<!DOCTYPE html>
|
|---|---|
| 2 |
<html lang="en-us"> |
| 3 |
<head>
|
| 4 |
<script type="text/javascript"> |
| 5 |
//Function which sends messages to the embedded training application
|
| 6 |
function sendAppMessage(msg) {
|
| 7 |
// handle message logic
|
| 8 |
}
|
| 9 |
|
| 10 |
//Function which sends messages to the parent window.
|
| 11 |
//Called from within the embedded training application
|
| 12 |
function sendTutorMessage(msg) {
|
| 13 |
parent.postMessage(msg, '*');
|
| 14 |
}
|
| 15 |
|
| 16 |
//Registers listeners for messages from the parent window
|
| 17 |
window.addEventListener('message', function(event) {
|
| 18 |
sendAppMessage(event.data);
|
| 19 |
}, false);
|
| 20 |
</script>
|
| 21 |
</head>
|
| 22 |
<body>
|
| 23 |
</body>
|
| 24 |
</html>
|