Closed anisfeld closed 9 months ago
~The iframe idea ran into a snag. For some reason, I can't see anything inside the iframe!!~
Update: If using ghostery or similar tracker blockers Qualtrics will fail to load in an iframe. Hopefully, they school laptops aren't running something like this.
It's tricky to get back to the platform from the iframe. Ideally, we have some information pass from qualtrics / iframe telling the webpage to close the iframe.
This post says we can pass a message back to the platform using parent.postMessage()
(https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage). Trying to figure this out. Current idea is when the "End of Survey" message is passed we
hat tip: https://javascriptbit.com/transfer-data-between-parent-window-and-iframe-postmessage-api/
Inside the html with the iframe.
{% block helper_script %}
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
if(event.data.includes("End of Survey")){
console.log("We're getting information across iframe")
window.location.href = "/games/{{game_id}}/player/{{player_id}}/round"
}
}
</script>
{% endblock helper_script %}
JavaScript on the Qualtrics side--afaik can be in any question on the last page of the survey. Try to keep it on the last question.
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
parent.postMessage("End of Survey", "*");
});
Superceded by #95 and #96
What Issue Are You Seeing or What Feature Needs To Be Added?
Are There Any Links That Would Be Helpful?