[open] How to insert HTML link to a webpage?
Hi,
I'm using a Form Text Render to display a goodbye message at the end of an experiment. I want to insert an HTML link that, when clicked, opens the site with a web browser (i.e., I want to direct participants to a particular website after completing the experiment in OpenSesame). How do I go about doing this? Thanks very much!
Comments
Hyperlinks are not supported in OpenSesame. But you can approximate this functionality by adding a button to your form, and use an
inline_scriptitem to open a specific URL in an external browser when this button is clicked.For example, if you create a
form_basewith the following script, you will see two buttons:If you click the button labeled 'Open http://www.cogsci.nl/', the variable
open_cogsciwill be set to 'yes', and you can use this to launch a webbrowser in aninline_scriptplaced after theform_base:Note that the resulting behavior may be a bit odd on some systems, because the OpenSesame window will loose focus, which is not what OpenSesame is designed for. But it might do the job for you.
Cheers!
Check out SigmundAI.eu for our OpenSesame AI assistant!
I'll try it and see whether it works. Thanks Sebastiaan!
Dear all
I would also like to add a link in OpenSesame which directs the participants to an online questionnaire (on Unipark). Is this still the only possibility to do so or is there an easier way by now?
I would like to give the participants brief instructions and then ask them to click on the link in order for them to get redirected to the online questionnaire.
Thanks in advance for your help!
Yes, this is still the only way. But it does what you want to do, right?
Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear sebastiaan
Sorry for my late answer! Yes, it does what I want it to do. I modified your version a bit. Instead of a form base I used a sketchpad and a response keyboard. I adopted your inline script and changed the answer:
This works just fine (thanks for the code)! I have just one problem: when I run the experiment in the fullscreen mode and I press the spacebar, the experiment closes but the website opens "in the background" - meaning that the link doesn't pop up, instead the OpenSesame menu is visible (the link opens but I have to actively click on the webbrowser to see the link). Does this make sense?
Is there a way to modify the code so the link pops up automatically (when I use the quickrun mode it works)?
Thank you for your help!
Erwin
Hi Erwin,
The easiest workaround is probably to run the experiment in a window, but have the window cover the entire display so that it's effectively full screen. You can do this as follows:
0,0.I suspect that the browser should now automatically get the focus when you open a url, just like when you use quickrun.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear all,
these comments on how to open a site with a web browser have been a great help.
I have a follow up question: is there a possibility to close the browser again or an other way to return to open sesame?
Thank you for your help!
Stephanie
Hi,
I would also like to redirect participants to an online questionnaire, on Framaforms. Using the script you provided, I didn't manage to make it work in OSWeb (my experiments are online).
Any suggestion?
Thomas
Hi @ChartTom ,
You can use
window.open()in aninline_javascriptitem to open a website in a new browser tab. If your online questionnaire has a URL, then this might work. Important: This is for OSWeb experiments! The discussion above refers to lab experiments, which require a very different solution!)window.open('https://osdoc.cogsci.nl')Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan
I have a follow-up question on this issue. I am doing an experiment online with OSWeb and used the solution you proposed to insert a link. My problem is that the link opens immediately when I start the experiment, is there any way that I can avoid this?
Thanks in advance,
Anna
Hi @atporrini ,
You probably inserted this code into the Prepare phase of the script. If you insert it into the Run phase, it will get executed when you expect it to. See also:
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks for post!