
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to Line Breaks to JavaScript Alert?
To add line breaks to JavaScript alert, use “\r
”. In the following example, we will see how to display text in JavaScript alert.
Example
<html> <body> <script> function DisplayAlert() { var newLine = "\r
" var msg = "Showing how to add line break." msg += newLine; msg += "Line Break can be easily added in JavaScript."; msg += newLine; msg += "Simply Easy Learning"; msg+= newLine; msg += "TutorialsPoint.com"; alert(msg); } </script> <input type = "button" value = "Click" onclick = "DisplayAlert()" /> </body> </html>
- Related Articles
- How to replace line breaks with using JavaScript?
- How to provide new line in JavaScript alert box?
- How to add line breaks to an HTML textarea?
- How to handle tabs, line breaks and whitespace in a text in JavaScript?
- What Are Whitespace and Line Breaks in JavaScript?
- How to replace line breaks in a string in C#?
- How to show hyperlinks in JavaScript alert?
- How to edit a JavaScript alert box title?
- How to center the JavaScript alert message box?
- How to create and apply CSS to JavaScript Alert box?
- How to design a custom alert box using JavaScript?
- How to show image in alert box using JavaScript?
- How to display JavaScript variable value in alert box?
- How to change button label in alert box using JavaScript?
- How to change the color of the alert box in JavaScript?

Advertisements