जावास्क्रिप्ट अलर्ट में लाइन ब्रेक जोड़ने के लिए, "\r\n" का उपयोग करें। निम्नलिखित उदाहरण में, हम देखेंगे कि जावास्क्रिप्ट अलर्ट में टेक्स्ट कैसे प्रदर्शित किया जाता है।
उदाहरण
<html>
<body>
<script>
function DisplayAlert() {
var newLine = "\r\n"
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>