Solved

How do I get a newline in a messagebox alert?

Posted on 2006-06-22
7
1,558 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now