Redirection to URL on object or word click

Description of the problem: I’m in the early stages of creating an experiment, and want to have a “right to withdraw” link which is clickable after each block of trials.

When the linked object is clicked, I want to end the experiment and redirect the participant to a Qualtrics URL which will be different to a URL that the participant would be directed to on the natural completion of the experiment. The click will direct participants to a debrief, and the natural completion will direct participants to a battery of questionnaires before the debrief.

How would you go about linking the URL to a clickable object/word, and is it possible to have this function present if redirecting to a separate URL at the end of the experiment?

Have you tried the incomplete and completed URLs in the online tab if experiment options?

Hi, thanks for the reply!

I think these functions will work in exactly the way I’m wanting, thank you! Is there a way to launch the incomplete URL on a valid mouse click i.e. clicking on a button marked “withdraw”? I would only want the incomplete URL function if they clicked the right button, or came out of the experiment in another way.

Thanks again

I’m currently invoking
psychoJS.quit({message: 'Please click to go to the participant information sheet'});
in Each Frame but the message only sometimes seems to appear.

Ah interesting. I’ll tinker with a similar function and see what I come up with. I’ll report back!

Hi, just wondering what you ended up doing for this? Looking for a way of doing something similar (sending participants to a standardised debrief page if they choose to end the study early)

Did you figure it out?

Could anyone help with Ral’s question? How can I create a clickable text or button that opens a new tab and directs the user to an external website? I’m looking for a simple and effective way to implement this. Any suggestions? I am not using the survey tool.

Have you tried my suggestion?

psychoJS.quit({message: 'Good bye!', isCompleted: false});

Note that the isCompleted flag should indicate whether you want to save the data (assuming save incomplete results is off). The default is false.

Hi @wakecarter!

Thanks for your help! I appreciate your response. However, I’m a bit puzzled about how to implement your solution.

  1. Where should I specify the URL that should open when the user clicks on the text or button?
  2. Where exactly should I insert this line of code? Should it go in the code component, or should I add it directly to the text component I want to make clickable?
  1. Experiment Settings / Online / Incomplete URL

  1. End Routine tab of a JS code component in the routine. For example:
if (mouse.isPressedIn(textComponent)) {
     psychoJS.quit({message: 'Good bye!', isCompleted: false});
}

For this to work you will need a mouse component called mouse, set to end the routine on a valid click. If your text component is actually a button then you could use

if button.numClicks {
     psychoJS.quit({message: 'Good bye!', isCompleted: false});
}

Please could you test and report back?

  1. Thanks, @wakecarter! The user is correctly redirected to the page specified in “incomplete URL.”
  2. Your code works when placed in the “Each Frame” tab, as shown below (pasting it here to help others with a similar issue):
  3. However, the message in my code (‘Thank you for your patience! Click “OK” to be redirected to Prolific. Goodbye!’) doesn’t appear in the closing message (see below). Since the page only opens when participants click “OK,” I’m concerned they won’t be redirected. I need either automatic redirection or a way to ensure they see the instruction to click “OK.”

How about trying to auto-click the button?