Solved

How do I get a newline in a messagebox alert?

Posted on 2006-06-22
7
1,561 Views
Last Modified: 2012-08-14
I have an ASP.NET web application that is using javascript to create messageboxes (see below)
<script language=JavaScript>alert(. . .

How do I get a newline in the messagebox?  Simply inserting a newline (as in controlchars.newline in ASP.NET) doesn't work.
0
Comment
Question by:stev0931
  • 3
  • 3
7 Comments
 
LVL 26

Accepted Solution

by:
DireOrbAnt earned 105 total points
ID: 16963789
Use \n as in:
alert('Hello!\nHow are you?')
0
 
LVL 10

Assisted Solution

by:0h4crying0utloud
0h4crying0utloud earned 20 total points
ID: 16964003



really? that always worked fine for me. even now with a quick test in IE and FF

Is is possible those chars are geting removed somewhere else?  you might wanna try using a double back slash "\\n" wherever you put in the newline.  
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 16964059
I was giving stev0931 the solution, not showing what he tried :)
Simply use \n inside single quoted strings and you should be fine :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16964125

oh those line were so close together I thought they were the same messsage!!! my eyes are going!
0
 

Author Comment

by:stev0931
ID: 16964223
The \n worked!  Thanks!
0
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16964658

Dang, I owe you DireOrb.
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 16965113
No sweat. It's out of my control :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now