Search code examples
javascriptqualtrics

Javascript window.scrollTo is ignored


I use Qualtrics to create an online questionnaire. I added this little piece of Javascript code to a question, consistent with Qualtrics Javascript API manual https://s.qualtrics.com/WRAPI/QuestionAPI/classes/Qualtrics%20JavaScript%20Question%20API.html):

Qualtrics.SurveyEngine.addOnload(function()
{
    console.log("Here I am...");
    window.scrollTo(0, 5000);
    console.log("... Now I am passed this section...");
});

I cannot show you, but this works perfectly in 'block view'. But as soon as I publish the full survey the scroll command is ignored or not working. Remarkably, I do see the print statements in the console. The code is accessed, but something seems to hinder the working of the scroll statement. As example. please see https://leidenuniv.eu.qualtrics.com/jfe/form/SV_9AeH7nkJsrIerDT for my survey with the Javascript code included (although not working). I am also puzzled why this does work in 'block view', but does not work in survey mode.

Any ideas why this does not work and/or suggestions to fix this? Thank you.


Solution

  • Block mode runs the older SE (Survey Engine), and your survey is running in the newer JFE (look at the address bar url to tell the difference). I don't know why scrollTo doesn't work in JFE. This isn't an ideal solution, but you can force your survey to run in SE by adding the parameter Q_JFE=0.