Skip to content

ErcanOPAK.com

  • ASP.Net WebForms
  • ASP.Net MVC
  • C#
  • SQL
  • MySQL
  • PHP
  • Devexpress
  • Reportviewer
  • About
JavaScript

New line in JavaScript alert box

- 19.08.2019.08.20 - ErcanOPAK

If you use with C# then \n will put a new line

alert("some text\nmore text in a new line");

Output:

some text
more text in a new line

When you want to write in javascript alert from a php variable, you have to add an other “\” before “\n”. Instead the alert pop-up is not working.

$text = "Example Text : \n"
$text2 = "Example Text : \n"
window.alert('<?php echo $text; ?>');  // not working
window.alert('<?php echo $text2; ?>');  // is working

 

Related posts:

Javascript Refresh and CountDown Timer
How to Auto-Refresh Page with Javascript
Get and Use TextBox Values with Javascript
How to use column search in datatable when responsive is false
How to refresh a DIV content with Javascript
Post Views: 1

Post navigation

Default Values for Data Types in C#
How to render HTML tags Asp.Net MVC

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

January 2021
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
« Nov    

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (243)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (194)
  • How to make some specific word(s) Bold or Underline in ReportViewer (187)
  • How to solve “Response.Redirect cannot be called in a Page callback” for DevExpress Components (182)
  • Confirm before process with ASPxButton in Devexpress (170)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (170)
  • Find numbers with more than two decimal places in SQL (168)
  • Devexpress ASPxGridview Column Grouping in Code (164)
  • DATEADD Function in SQL (163)
  • Tense Changes When Using Reported Speech (160)

Recent Posts

  • How to auto-scroll or manually to end of div when data is added
  • Filter Rows By Max Date in SQL
  • How to Validate a DateTime in C#?
  • Convert comma separated string into a List in C#
  • Converting a List to a comma separated string in C#
  • How to add placeholder to Multiple Selection DropDownList in Asp.Net MVC
  • How to use toFixed() for Float numbers in Javascript
  • Convert List to List in one line in C#
  • How to use column search in datatable when responsive is false
  • Checking multiple contains on one string

Recent Posts

  • How to auto-scroll or manually to end of div when data is added
  • Filter Rows By Max Date in SQL
  • How to Validate a DateTime in C#?
  • Convert comma separated string into a List in C#
  • Converting a List to a comma separated string in C#

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (243)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (194)
  • How to make some specific word(s) Bold or Underline in ReportViewer (187)
  • How to solve “Response.Redirect cannot be called in a Page callback” for DevExpress Components (182)
  • Confirm before process with ASPxButton in Devexpress (170)

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter

Copyright © 2021 ErcanOPAK.com | powered by XBlog Plus WordPress Theme