Solved
Using iframe API to automatically advance to next page after a video has been watched
I’d like to present several clips. Immediately after a particular clip is viewed, the survey automatically advances to the next page where the respondent answers questions. Next, another clip is presented. After that clip is viewed, the survey again advances to the next page where the respondent answers more questions. The NEXT button is hidden since I do not wish the respondents to skip watching the videos.
The problem is that the code works perfectly if I have only a single video in my survey, but if I include a second video, the survey does not advance to the next screen once that second video is completed. There is also no initial alert, which suggests that the event calls for the second video do not execute.
I’m hoping that you could help me figure out where I’ve gone wrong and correct the problem. Thank you in advance!
Here is a direct link to the example that illustrates the problem I’m experiencing: the survey advances automatically after the first clip but not after the second one:
https://stlawu.qualtrics.com/jfe/form/SV_50TVe8wS1JC44nP
1. I placed the following in the header (Look & Feel/Advanced/Header):
script src="https://stlawu.az1.qualtrics.com/ControlPanel/File.php?F=F_5tcW6K6DuYVG57L" type="text/javascript"></script>
2. This is the HTML code placed with the first clip (note that the video is just a short YouTube video for illustration purposes):
iframe id="video1" allowfullscreen="" frameborder="0" height="360" width="640" src="https://www.youtube.com/embed/NOQDkYzhmho?enablejsapi=1&controls=0&disablekb=1&modestbranding=1&rel=0&showinfo=0&iv_load_policy=3" type="text/html"></iframe>
3. This is the HTML code placed with the second clip:
iframe id="video2" allowfullscreen="" frameborder="0" height="360" width="640" src="https://www.youtube.com/embed/pCCV3SKcJao?enablejsapi=1&controls=0&disablekb=1&modestbranding=1&rel=0&showinfo=0&iv_load_policy=3" type="text/html"></iframe>
4. Finally, since I don’t want to display the Next button when the videos are displayed, this Javascript is placed under Qualtrics.SurveyEngine.addOnload(function() for both first and second video clip questions.
this.hideNextButton();
_Note that I omitted "<" from the beginning of the code in 1, 2, and 3 to be able to paste the code here._
Best answer by mattyb513
I'm having a hard time debugging, but it might be handy to know that Qualtrics isn't reloading the page each time the page turns, instead just reloading the theme, which includes your custom header/footer. It acts as a single page app, so the `document` and `window` stay the same. Perhaps something is getting cached or stored in those places.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.