javascriptalert

Multi-line alert in Javascript


This code

alert("Hello again! This is how we" + "\n" + "add line breaks to an alert box!");

doesn't work. Firefox JavaScript console names error as "unterminated string literal" and points on " symbol before \n. I want to fire an alert with multi-line text. No jQuery please.


Solution

  • Haven't tested but does this work?

    alert("Hello again! This is how we \n add line breaks to an alert box!");