How to set text alignment for OSweb
Hi everyone!
I'm currently building an online experiment using OSweb extension.
I've now encountered a problem where text I set in a JavaScript inline script is always aligned to the left in sketchpads and feedback items, whereas text written directly in the sketchpad or feedback item is by default centered (which I prefer). This only occurs when the experiment is run in browser. In the local OpenSesame client the programmatically set text is actually centered.
For reference:
I define the text in the inline script with:
var text_1 = "This is text_1";
vars.text = text_1;
And in the textline element in the sketchpad:
[text]
I've also tried to use the HTML code to set alignment, both in the script (as var text_1 = "<p style=text-align:center;>This is text_1</p>;") and in the textline element (as <p style=text-align:center;>[text]</p>), but it doens't make a difference.
Would any of you have an idea how to achieve center alignment for text set in JS inline script?
Comments
Hi,
Could you attach the experiment, or a variation thereof that illustrates the issue, to this discussion? That might clarify where this seemingly odd issue comes from.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
I've attached a reduced version of my experiment.
In it, the inline scripts "support_high_load_practice" and "support_block_finished_text" are used to set the text for the sketchpads "high_load_practice_text_2" and "block_finished_text" respectively.
Thanks!
Hi,
Ah—thanks for reporting this. For some reason, indicating line endings with
\ndoesn't work properly, and indeed breaks the center alignment. I filed an issue for that. For now, a simple workaround is to use<br />tags to indicate line endings instead.Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
That works. Thank you so much!
Good luck with the rest of development!