Window.open in the same tab and saving data

URL of experiment: N/A

Description of the problem:

If I use window.open("https://www.myaddress.com","_self"); at the end of my survey, could this cause issues with saving data since this is going to open a new page in the same tab? So far, I’ve used it without _self and it works OK, but I am really bothered by the fact that Pavlovia tab stays open and someone can keep clicking the refresh button in their browser after a test and eat up my credits. Or is there another, more efficient way of preventing this rather than redirect in the same tab?

Thanks

Hi @pavle, are you aware of the “Completed URL” option in experiment settings → online? This allows you to redirect your participants to a URL after completing your experiment.

Thanks @ajus for your suggestion. Unfortunately, I cannot use this option since depending on their overall score (if they’ve passed or failed the test), I redirect them to different web addresses (in the code) plus I add a few parameters to URLs.

You can use code and variables in this field. So your requirements should not be a problem!

E.g.,

if(score >= 20){
    end_url = "www.google.com"
    }else{
        end_url = "www.yahoo.com"
        }

and then use $end_url in the “Completed URL” field.

Have you tested this? I’ve always had to use a code component of setRedirectUrls in a code component. If the completed URL takes any variables other than expInfo set at the start then that’s news to me.

1 Like

Ah, true! I did never notice that since I always use expInfo variables. So @pavle could use something like

if(score >= 20){
    end_url = "https://www.google.com"
    }else{
        end_url = "https://www.yahoo.com"
        }

psychoJS.setRedirectUrls(end_url, '');


1 Like