Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to add newline character in Text in Javascript?

Community Beginner ,
May 31, 2011 May 31, 2011

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

TOPICS
Scripting
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guide ,
May 31, 2011 May 31, 2011

'\r' works fine for me…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2011 May 31, 2011

either, single or double quotes work on windows

textFrame.contents = "Some\rtext.";

textFrame.contents = 'Some\rtext.';

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 01, 2011 Jun 01, 2011
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines