00 Votes

JavaScript: alert() with line break

Question by Compi | 2016-08-25 at 22:43

I would like to output some information using the JavaScript dialog alert(). The problem is that the text is becoming messy if it is too long.

Therefore, I am searching for a possibility to create a multi-line message box with wordwrap. Is this possible using JavaScript?

ReplyPositiveNegative
0Best Answer0 Votes

Yes, you can create a line break with inserting a \n into your string.

For example like that:

alert('A\nB\nC');

The \n will be replaced by a jump into the next line when outputting, so that this example creates a message dialog containing A, B and C under each other each letter in a separate line.
2016-08-26 at 17:29

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.