Hi All,
This is a strange one... I get an ‘Aw Snap’ error in Chrome when I am on a page which has had some JS code running to add in some pictures before and after some specific labels. This code normally runs fine but on this occasion the error occurs specifically when I go into inspect (ie ctrl+shift+c) / the debug console window. It doesn’t seem to happen any other time.
This is the code that was causing the issue
Qualtrics.SurveyEngine.addOnReady(function()
{
var sad_face_scr = 'https://warnerhotels.eu.qualtrics.com/CP/Graphic.php?IM=IM_8qBpza9jCsgHZ7D';
//The backslash \ identifies that the code continues on a new line but be careful of spaces and apostrophes
//The backslash must not have anything afterwards, not even a space!
//There is a space here: append(' < so that the image doesn't touch the end of the choice answer
jQuery("#" + this.questionId).find('li.first>span').append(' <img id="sad_face" src=' + sad_face_scr + ' \
style="width: 31px; height: 30px; vertical-align: middle;" />');
});
If I replaced the image and styling with some simple text that works fine - no crashing when going into inspect. I then tried (by a stroke of luck) the jQuery all on one line, ie this.
Qualtrics.SurveyEngine.addOnReady(function()
{
var sad_face_scr = 'https://warnerhotels.eu.qualtrics.com/CP/Graphic.php?IM=IM_8qBpza9jCsgHZ7D';
//The backslash \ identifies that the code continues on a new line but be careful of spaces and apostrophes
//The backslash must not have anything afterwards, not even a space!
//There is a space here: append(' < so that the image doesn't touch the end of the choice answer
jQuery("#" + this.questionId).find('li.first>span').append(' <img id="sad_face" src=' + sad_face_scr + ' style="width: 31px; height: 30px; vertical-align: middle;" />');
});
And this now works fine!
In addition to this, I normally would use this code in the addOnLoad() function but because I’m making some changes to the labels of the slider question via the addOnLoad function first (see below code), the above code I’ve discovered needs to be in the addOnReady section.
Please can I get some thoughts on this issue. Is this a bug in that Chrome can’t cope with this ‘\’? I use this code quite alot as the window I have to work in within Qualtrics is rather small. I have never had this problem before but this is the first time I’ve had to place this code in the addOnReady() function.
Is there another way to have this code in the addOnLoad() function?
Thanks
Rod Pestell
For context this is my addOnload() code that repeats the labels and hides the first set of a slider question. I then want to add smiley faces to the beginning or end of each label (using the above code).
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
jQuery('#' + this.questionId + ' .QuestionText').css({'padding-bottom':'0px'})
//=====code to repeat the label for each slider and remove the first one
let labs = document.querySelector(".labels-container"),
sliders = document.querySelectorAll(".slider-container");
for (let i = 0; i < sliders.length; i++)
slidersdi].insertAdjacentHTML("beforeend", labs.outerHTML);
jQuery('#' + this.questionId + ' .numbers').css({'visibility':'hidden'})
jQuery('#' + this.questionId + ' .labels-container:first').css({'visibility':'hidden'})
//======end code
});