I am trying to broadcast a message to an HTML file and don’t understand why it is not working
Message Broadcast:
top.postMessage('question set', 'play.js')
Message Interpretation:
let questionNameDisplay = document.getElementById('question-name-display')
window.addEventListener('message', function (event) {
if (event.origin === 'play.js') {
if (event.data === 'question set') {
questionNameDisplay.innerHTML = `QUESTION SET`
}
}
})
Can anybody identify any errors? Thanks!