JavaScript - \n can't be used in text

projetmbc2 shared this question 2 years ago
Answered

Hello.I can't use \n in JavaScript scripts to update a text in the graphic.

I must use \r but on Unix, this implies to click on a text after the update of its content and then to click on the OK button to see the new lines printed.


This sounds like a bug.

Comments (2)

photo
2

This is what you want

text = "One line\\\\nAnother...";
ggbApplet.evalCommand('SetValue(unixtxt, "' + text + '")');

photo
1

Thanks a lot for the trick even if I know the double escaping technic.

This still sounds weird for me because of the behavior with the \r... o_O

© 2023 International GeoGebra Institute