Input and output One of the best features of the Web is that it is interactive. Using JavaScript, it is possible to program a web page to output information to the user in different forms, as well as to accept input from the user in various ways.
An alert box can be created inside a <script> tag
The value of the variable to display in the alert box
<div id="name"> <script>
<script>
The document object can be accessed inside a <script> tag
The value of the variable to write to document.write(name); the screen
var name = "Alice";
var name = "Alice"; alert(name);
</script>
</script>
</div> The alert method displays an alert box
The document.write method inserts text into the HTML
Insert data into the HTML output This allows programmers to execute JavaScript and output some data into the HTML at the exact location where they want the output to appear on screen.
Show a modal alert box An alert box is a modal window that opens above the normal browser window with a message. Users cannot continue until they dismiss the alert box.
User input There are several ways to capture user input and work with the data in JavaScript. The choice of input method depends on the degree of urgency involved in entering the data, whether the input fields need to conform to the visual style of the page, or whether the user must answer the questions in a specific order.
Prompt A prompt is a modal message box that asks the user for a single line of input. The user must answer the question before doing anything else in the browser. Prompts are helpful in cases where the user must answer questions urgently or in a specific order.
This page says Please enter your first name
Cancel
OK