Javascript Browser Window alert() Method with line breaks

Introduction

Alert box with line-breaks:

alert("Hello\nHow are you?");

Click the button to demonstrate line-breaks in an alert box.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*  www  . j  a  v  a  2  s .com*/
  alert("Hello\nHow are you?");
}
</script>

</body>
</html>



PreviousNext

Related