How to add newline character in Text in Javascript?
Copy link to clipboard
Copied
I have a Text Frame object. Call it textFrame. If I do
textFrame.contents = "Some text.";
The script changes the text as expected. But what if I want to have the text span several lines? If I do:
textFrame.contents = "Some\ntext.";
The type just shows the "\n" rather than inserting a newline. I've tried "\r" too but no dice. Is there some special way to add a newline character when assigning a value to the contents property of a TextFrame object?
Thanks!
Ben
Explore related tutorials & articles
Copy link to clipboard
Copied
'\r' works fine for me…
Copy link to clipboard
Copied
either, single or double quotes work on windows
textFrame.contents = "Some\rtext.";
textFrame.contents = 'Some\rtext.';
Copy link to clipboard
Copied
Bizarre. I'll try restarting the program and fiddling some more. No idea why the \r and \n were just showing up in the text for me. But thanks for letting me know it should work.
Cheers,
Ben

