Popup Boxes In JavaScript: Part 1

Alert Box

An alert box is often used if you want 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

A LineBreak alert box 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 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()" />&nbsp;&nbsp;

        <input id="Button2" type="button" value="Show LineBreak Box" onclick="ShowLinkBreak()" /></p>

</body>

</html>

 

Output 1

Click on the ShowAlert button.

 alert-box.jpg


Output 2

Click on the ShowLinkBreak button.

line-break-box.jpg

For more information, download the attached sample application.

Up Next
    Ebook Download
    View all
    Learn
    View all