Hello! First, I want to preface my (first-ever) post with the declaration that I am a relative newcomer in terms of both HTML and JavaScript. As such, I apologize in advance for any clarifications I will inevitably ask while seeking assistance! On to the problem:
Akin to the query asked in this thread, I am looking to embed an HTML-based game directly into a Qualtrics question. While I am capable of embedding an image that links to a new window containing the game, I need to be able to restrict participants' time with the game using the Page Timer feature. As I understand it, any requisite JavaScript libraries would need to be included in the Header of the survey, and any HTML would go in the Source of the question.
For some additional background, I originally attempted to embed a game from htmlgames.com - specifically, Cube Crash (about a third of the way down that list), and was met with the error "ERROR: Please provide a 'game' argument!" This brings us back to my disclaimer - I am unsure as to what causes that error because of my limited experience with JavaScript. Further, when attempting to add the JavaScript directly to the header of my survey, I'm informed that I can't use the document.write function (which, as I understand it, replaces everything previously existent on the page with the game). I'm unsure how/if I can edit that out.
I think that's the bulk of my issue. If anyone has any advice on how to tackle this issue or alternative solutions, I would greatly appreciate the help. Thanks!
Solved
Embedding an HTML-Based Game
Best answer by Anonymous
Hello @SomervilleC ,
Rather than using embed you can use iframe and in src attribute pass the url of the game.
Here I have used htmlgames.com fishing trip.
Steps to do are as follows:
1. Add the following code in the rich content editor(HTML View) of the descriptive text question
!
2. Add the following code in the look& feel -> advanced -> add custom css
#NextButton {
display:none;
}
.resp-container {
position: relative;
overflow: hidden;
padding-top: 56.25%;
}
.resp-iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
Image:
!
3. Preview the survey and the output is shown in the image below:
!
Note: On just changing the src of iframe from htmlgames.com , you can create different embedded html games.
Here is the preview Link
Please find the attached qsf file.
View originalRather than using embed you can use iframe and in src attribute pass the url of the game.
Here I have used htmlgames.com fishing trip.
Steps to do are as follows:
1. Add the following code in the rich content editor(HTML View) of the descriptive text question
!

2. Add the following code in the look& feel -> advanced -> add custom css
#NextButton {
display:none;
}
.resp-container {
position: relative;
overflow: hidden;
padding-top: 56.25%;
}
.resp-iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
Image:
!

3. Preview the survey and the output is shown in the image below:
!

Note: On just changing the src of iframe from htmlgames.com , you can create different embedded html games.
Here is the preview Link
Please find the attached qsf file.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.