How do you put in a new line into a JavaScript alert box?
How do you put in a new line into a JavaScript alert box?
As of ECMAScript 2015 you can use back-ticks (` `) to enclose Template Literals for multi-line strings like this:
alert(`Line1
Line2`);
Outputs:
Line1
Line2
You can use \n for new line
alert("Welcome\nto Jumanji");
alert("Welcome\nto Jumanji");
In JAVA app, if message is read from "properties" file.
Due to double compilation java-html,
you'll need double escape.
jsp.msg.1=First Line \\nSecond Line
will result in
First Line
Second Line