0% found this document useful (0 votes)
15 views5 pages

JavaScript Output Methods Explained

The document explains methods for displaying output in web pages using JavaScript, including document.write, document.writeln, and window.alert. It provides examples of each method, demonstrating how to output text and perform calculations. The alert method is highlighted for displaying messages to users through an alert box.

Uploaded by

Prema Ranganath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

JavaScript Output Methods Explained

The document explains methods for displaying output in web pages using JavaScript, including document.write, document.writeln, and window.alert. It provides examples of each method, demonstrating how to output text and perform calculations. The alert method is highlighted for displaying messages to users through an alert box.

Uploaded by

Prema Ranganath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Screen output and keyboard input:

Methods to show output


[Link] or [Link]
[Link]
[Link]

[Link]

Example 1:
<html>
<head>
<title>write and writeln</title>
</head>
<body>
<ul>
<li>HTML
<li>CSS
<li>Jvascript
</ul>
<input type="button" value="click"
onclick="[Link]('i will delete you')">
<script>
[Link]('hello');
[Link](4+6);
</script>
</body>
</html>
[Link]() method:
Example:
<html>
<head>
<title>write and writeln</title>
</head>
<body>
<ul>
<li>HTML
<li>CSS
<li>Jvascript
</ul>
<script>
[Link]("<pre>hello");
[Link]("4+6" + "= " +(4+6));
[Link]("</pre>");
</script>
</body>
</html>
[Link]() Method:

Description
The alert() method displays an alert box with a message and an OK button.

The alert() method is used when you want information to come through to the
user.

Example:
<!DOCTYPE html>
<html>
<body>

<h1>The Window Object</h1>


<h2>The alert() Method</h2>

<p>Click the button to display an alert box.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
alert("Hello! I am an alert box!");
}
</script>
</body>
</html>

You might also like