advance external-html after a certain delay without any other triggers #1022
-
I would like to present an external html page for a certain amount of time without having to wait for any other kind of input from the participant - is this possible and if so how? Thanks in anticipation, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @Quinlanptq, I think there probably are a couple ways to do this, and I'm not sure which is best. You could use the trial's on_start or on_load function to start a timer using setTimeout. The first setTimeout argument would be a function that ends the trial by calling jsPsych's finishTrial function, and the second argument would be your delay in ms. on_load: function() {
setTimeout(function() {
jsPsych.finishTrial(); // call the finish trial function after 5 seconds
}, 5000);
} Keep in mind that, if it's possible for the trial to end any other way (e.g. participant's button or key press), then you'll want to make sure that you assign setTimeout to a variable and then clear the timeout at the end of the trial using clearTimeout. One potential problem with this method is that the var trial = {
type:'external-html',
url: "external_page.html",
cont_btn: "hidden-button",
on_load: function() {
setTimeout(function() {
document.getElementById('hidden-button').click();
}, 5000);
}
}; Let us know if one of these solutions work. And I'd be interested to know if anyone else has other suggestions. |
Beta Was this translation helpful? Give feedback.
-
Hi Becky |
Beta Was this translation helpful? Give feedback.
-
This method is so genius! I used it in my experiment! I have a trial that involves card selection, where participants need to choose one card from several. In fact, besides the external HTML plugin, I didn't know which plugin could accomplish this task well (other plugins all have their own buttons or something that I don't need). But the problem with the external HTML plugin is that I couldn't make participants finish this trial by clicking on the cards. The hidden button method is simply fantastic! Hats off to Becky! |
Beta Was this translation helpful? Give feedback.
Hi @Quinlanptq, I think there probably are a couple ways to do this, and I'm not sure which is best.
You could use the trial's on_start or on_load function to start a timer using setTimeout. The first setTimeout argument would be a function that ends the trial by calling jsPsych's finishTrial function, and the second argument would be your delay in ms.
Keep in mind that, if it's possible for the trial to end any other way (e.g. participant's button or key press), then you'll want to make sure that you assign setTimeout to a variable and then clear the …