| Reference | Downloads | Github

Solutions worked offline, but not running Online (hide mouse, add break)

URL of experiment: EP_12.7.21 [PsychoPy]

Description of the problem: The following codes do not work when I run the experiment online.

  1. Hide mouse in the beginning of the experiment

win.mouseVisible = False

vs. Auto to Java:

win.mouseVisible = False

  1. Make break every 96 trials in the beginning of the routine

if MainExp.thisN == 0 or MainExp.thisN % 96 != 0:
continueRoutine = False

Auto to Java:

if (((MainExp.thisN === 0) || ((MainExp.thisN % 96) !== 0))) {
continueRoutine = false;

Both solutions I adopted (= copy past with changing numerical value for the second piece) from this forum. They work offline only.
That is, the mouse is visible all the experiment in the browser window; I have break screen every trial.
Could somebody be so nice and help me?
I will greatly appreciate your help and time,

Hi Dina,

an easy solution for the non-hidden mouse, is to use a javascript-only code block at the beginning of the experiment (maybe at the beginning of the first routine) with this content:'none';

This will hide the cursor entirely.

A simple solution for the non skipped Break-Message could be:
Place the skip code in the “Every Frame” part of the code block.

If this is not working:

MainExp.thisN might return the total number of trials in the Loop, instead of the currentTrial index.
You can simple use a variable at the beginning of the loop:
trialCounter = 0

and count up the trialCounter after each trial with:

Use the trialCounter instead of MainExp.thisN - (check also the Crib Sheet
PsychoPy Python to Javascript crib sheet 2021 - Google Docs)

The link to your experiment isnt working, so i am not 100% sure if my suggestions will solve your problem.


Hi Luke,
thank you very much for your prompt reply! The‘none’;

worked perfectly.
Adding myCounter according to the crib sheet instructions solved the second problem, I switched the code component for break to “Both”.
Since I now removed the debugging version of the experiment from pavlovia, I am attaching the code to my reply. I hope it can be helpful to other people (not adding tones of stimuli).
Thank you very much!
EP_22.7.21.psyexp (94.5 KB)

Hi Luke,
may I ask you a follow up question?
How can I save myCounter data to the csv (offline and online)?
Currently I have csv output with .ThisN saved automatically, separately for practice loop and main experiment loop. Eventually, I would like to have a trial number for practice and main part (starting from 0 in main experiment) in one column of the csv output.
I will greatly appreciate you help.
dina_EP_25.7.21Full_2021-07-29_10h11.27.991.csv (101.9 KB)
EP_25.7.21Full.psyexp (90.7 KB)

You can use an easy solution proposed by the Cribsheet PsychoPy Python to Javascript crib sheet - Google Docs

Use a JS-Code-Only Code Component at the beginning of the experiment to map the “thisExp” PsychoPy correctly to the JavaScript thisExp-Version:


If you have done this, you can use the standard function to add data to the trial file:

thisExp.addData('Column-Name', DATA);

In your case you can at the counter variables at the end of the trial in a “Both” Code Component:

thisExp.addData('myCounter', myCounter)

this would be translated to Javascript like this:
thisExp.addData('myCounter', myCounter); (only adds the semicolon)


1 Like

Thank you very much!!