-
Hi everyone! I am having trouble running the following code:
When I try to run that code in Visual Studio Code, my debug console says this: "Uncaught TypeError: Cannot read properties of null (reading 'getContext')." I know that this has something to do with the fact that I am calling the canvas element from inside a jsPsych function, because the code works fun when run in regular JavaScript. Unfortunately, I'm not sure what my syntax error is. If someone has an idea as to what my error(s) could be, would you please share your thoughts here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @woodenchair, The problem here is that when jsPsych starts running the experiment it removes all of the content from the One option would be to use the Another option is to use the |
Beta Was this translation helpful? Give feedback.
Hi @woodenchair,
The problem here is that when jsPsych starts running the experiment it removes all of the content from the
<body>
element in order to display the experiment content.One option would be to use the
canvas-button-response
plugin, which renders a canvas on the screen for you and you can draw on it using code similar to what you have right now.Another option is to use the
display_target
parameter in jsPsych.init to render your experiment in a different element than the body. This would let the canvas element stay on the screen after jsPsych begins.