Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple lines in Alert Box Message

Status
Not open for further replies.

HungryH

Programmer
Sep 25, 2001
2
GB
I know how to use alert boxes. I just want to know how to place a message with multiple lines in an alert box. I have tried using \n and \r between the lines but it only creates an error in the browser.

Can anyone help?
 
\n is the way to do it. Here's an example:

alert('Hi\nthere');

Will look like:

Hi
there

:)
penny.gif
penny.gif
 
Just to tack on to what link9 already said, you can also concatenate several strings together like so:
Code:
var myMsg = "This is a message\n";
myMsg += "This is the second line\n";
myMsg += "This is the third line\n";
myMsg += "End of message.";
alert(myMsg);
But the concept is still the same. Have fun! Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top