Click here to Skip to main content
16,015,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How do i add a break in line in confirm box using JavaScript?

var response=confirm("You are reporting for the sources on this property are not yet complete. You will need to return to this website or submit paper forms for the unchecked sources in order to finish your anuual reporting.Do you want to proceed?");

I tried
,
, /n, \n etc., nothing works.

Please help!!

Thank you
Posted
Updated 21-Sep-18 6:39am

Try using \r\n for a line break - you need a carriage return (\r) and a line feed (\n). (chr(10) + chr(13) or 0x0A + 0x0D). Windows expects both. Linux and Mac only need one of them.

JavaScript
confirm('Hello\r\nLine2\r\nLine3');


works for me.
 
Share this answer
 
v2
Comments
pentyd 15-Mar-12 10:18am    
Thanks
Aditi Sarkar 4-Dec-13 22:41pm    
Thanks for the solution.
instead of string quotes using tilda quote
ex: confirm(`this
is
a
tilda
quote`);

this quote is in the keyboard.Below the Esc button.
 
Share this answer
 
Comments
Richard Deeming 21-Sep-18 14:40pm    
Template literals[^] were not an option when this question was posted. They first appeared in a major browser in December 2014. Internet Explorer still doesn't support them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900