Pavlovia experiment throws unspecified javascript error

URL of experiment:

Description of the problem:
Hi all, long time psychopy user here, just starting with Pavlovia. I programmed a Stroop task that works fine online on its own, but then I added an Ishihara color test before the task and now I get an “Unspecified Javascript error” after entering participant number at experiment start. Here are the details:

I present PNGs of 12 Ishihara plates, one after the other. Along with the image, I present a Slider (with “radio” type checked in the Appearance settings) on which participants can select the number that appears in the image (ticks = 1-11, labels=11 labels for different numbers, as the number 5 is repeated twice). Unbeknownst to subjects, a hidden text number appears along with the image, so I can keep track of which number is actually shown in each image. After the participant clicks the rating on the Slider, they are provided feedback about whether the label of the Slider rating they clicked matched the hidden number in the Ishihara plate.

I wrote a code component to deliver feedback like this. In Psychopy, it looks like this:
Begin experiment:


Begin routine:

rat2lab = int(rating.getRating()) - 1

rating_label = str(rating.labels[rat2lab])

if rating_label == ishi_text.text:#stored on last run routine
msg2="Oops! That was wrong. Contact the experimenter if you could not see the number. If you just made a mistake, press ESC and start over again."

I then did Auto–>JS. In JS, it looks like this:
Begin experiment:

msg2 = “”;

Begin routine:

rat2lab = (Number.parseInt(rating.getRating()) - 1);
rating_label = rating.labels[rat2lab].toString();
if ((rating_label === ishi_text.text)) {
msg2 = “Correct!”;
dur = 1;
} else {
msg2 = “Oops! That was wrong. Contact the experimenter if you could not see the number. If you just made a mistake, press ESC and start over again.”;
dur = 100;

Then, in the feedback message (just a textbox), duration is $dur and text is $msg2. That way, if participants make a mistake, they are stuck on that image and are told to press ESC to exit the experiment.

I’m pretty sure there is something in this code that is messing up in the translation from python to JS, because it works fine in psychopy on my desktop. As a note, in my code it says “rating” - I called my Slider “rating”, I did not use the old “rating” component, which I read does not work in Pavlovia.

If anyone can offer a solution, it would be so wonderful, I’ve been stuck on this for hours and haven’t found a solution yet. I feel like I’m so close to getting this running!

Thanks for reading!

I have groups successfully running an Emotional Stroop task but some participants are reporting an unspecified JavaScript error. I don’t yet have information about which devices or browsers are failing.

@kerblooee when I run your task I don’t get any error (at least not for the first trials I tested). Is there something specific I need to do to make the error occur? Could you make a “Minimal Working Example” of the error occurring so we can work out what’s going wrong?

Hi Jon,
I found out my error was in trying to present the ishihara color plates as PNGs. The code may be another issue. I thought the issue might be with how I defined image paths (e.g.
“ishihara/Plate1.png”), so I put the images into the main experiment folder and made the path only the image name (e.g. “Plate1.png”). This still gave me an unspecified javascript error, so I gave up for today, but I’m going to try again tomorrow. I will recreate the error!

Dear @wakecarter, I got exactly the same problem at the moment. My experiment was running fine for most participants, but one received the mention “Undefined Javascript error” for unknown reasons, as I didn’t touch upon my code. Did you get an idea of how to solve this? Thanks!

Hi Katy,
In the end, I had to remove all interactive parts from the experiment, mainly a slider that I had added to every trial. A colleague of mine suggested having a screenshot of a slider and asking participants to respond using the 1-5 keys on the keyboard. It’s a rough fix, but it works…

Sorry I couldnt be of more help… I don’t think Pavlovia is very compatible with interactive experiments, it seems to work best with short “slideshow” type designs.

1 Like

Same! I’ve already a bunch of participants but some are reporting this error. Any updates?

Same issue here. Any updates on possible fixes?

Might not be helpful, but I encountered the unspecified Javascript error when I made a blank ISI (blank text component). Despite no text being shown, inputting a decimal letter height (0.1) with pixels as the default experimental unit produced an unspecified Javascript error. Given that most experiments use ISIs, it may help at least some of the people here to double-check the units of your components.

Decimal text heights in pixels does seem to be one of the most common causes of this error

I have the same issue, only one of the participants is getting the error. Do we know what causes it. Can this be an issue on the participant side, due to browser security? Why only some see this and most don’t?

I am also getting this issue for about 5% of participants.

If the experiment works on some browsers but not others try editing the index.html file directly to replace

<script type="text/javascript" src=""></script>


<script type="text/javascript" src=""></script>

Might be worth checking participants switch off any Ad Blocker type software. We had an issue with that, where it worked for some but not others. It was not an unspecified jaavascript error though, but something to consider anyway.