-
Book Overview & Buying
-
Table Of Contents
JavaScript Projects for Kids
By :
In the previous chapters, you learned how to print something using document.write(). Now, you will learn something more.
We will check the methods on both console and HTML document, as follows:
To show an alert or a pop-up box using JavaScript, we use the following method:
alert("Hello World");Type this on the console and press Enter, you will see a pop-up box saying Hello World:

You can write your code to show a pop-up box similar to the following on an HTML document:
<html>
<head>
<title>Alert</title>
</head>
<body>
<script type="text/javascript">
alert("Hello World");
</script>
</body>
</html>The output will be as follows:

If you want to take information from users, you need to use a prompt box to do this. Consider the following for example:
You want to take input of the username and print it on the main web page.
You can do this using the window.prompt() method.
The structure of window.prompt...
Change the font size
Change margin width
Change background colour