Solved

How do I get a newline in a messagebox alert?

Posted on 2006-06-22
7
1,565 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

730 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