Alert Box in JavaScript
An alert box in JavaScript is often used to ensure information comes through to the user, and it displays some information to the user.
Function
function ShowAlert()
{
alert("Hello C-sharpcorner");
}
LineBreak Box in JavaScript
A LineBreak alert box in JavaScript is often used to display line breaks inside a popup box. Use a backslash followed by the character n.
Function
function ShowLinkBreak()
{
alert("Hello \n C-sharpcorner");
}
The following example shows how to display popup boxes in JavaScript.
Complete JavaScipt Program
Alert_LineBreaks_PopupDemo.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function ShowAlert()
{
alert("Hello C-sharpcorner");
}
function ShowLinkBreak()
{
alert("Hello \n C-sharpcorner");
}
</script>
</head>
<body>
<p>
<input id="Button1" type="button" value="Show Alert Box" onclick="ShowAlert()" />
<input id="Button2" type="button" value="Show LineBreak Box" onclick="ShowLinkBreak()" /></p>
</body>
</html>
Output 1
Click on the ShowAlert button.
Output 2
Click on the ShowLinkBreak button.
Summary
For more information, download the attached sample application. I recommend you read my next article for more details about Popup Boxes in JavaScript.