如何在JavaScript警告框中添加新行?
当前回答
我使用了:"\n\r" -它只能在双引号中使用。
var fvalue = "foo";
var svalue = "bar";
alert("My first value is: " + fvalue + "\n\rMy second value is: " + svalue);
will alert as:
My first value is: foo
My second value is: bar
其他回答
使用javascript的新行字符代替'\n'.. "Hello\nWorld"使用"Hello\x0AWorld" 效果很好!!
警报('交易已被批准。\ nThank你);
只需添加一个换行符\n。
alert('The transaction has been approved.\nThank you');
// ^^
你可以用\n表示新行
alert("Welcome\nto Jumanji");
警报(“欢迎\ nto Jumanji);
在JAVA应用程序中,如果消息是从“属性”文件中读取。
由于双重编译java-html,
你需要双重逃生。
jsp.msg.1=First Line \\nSecond Line
会导致
First Line
Second Line
Alert ("some text\nmore text in a new line");
输出:
一些文本 新行中有更多文本