Chapter 5 - JavaScript in HTML Documents
Chapter 5 - JavaScript in HTML Documents
Copy Work
Date: __/___/____
CHAPTER 5
JAVASCRIPT IN HTML DOCUMENT
KEYWORDS:
<script> tag, variable, operators, document.write(), parseFloat(), parseInt(), Script block, window.alert(),
window.confirm(), windowprompt(), String concatenation.
d. Display a confirm dialog box with the message “Plant more trees”.
<HTML>
<BODY>
<SCRIPT language=“JavaScript”>
document.write(reply);
</SCRIPT>
</BODY>
</HTML>
b. window.prompt(): The prompt dialog box is also a method of the window object. This method is used
for getting input from the user. It displays a Explorer User Prompt dialog box with a message, and an
input field.
c. window.alert(): window. alert () is a method of the window object. It is the simplest dialog box used
to display a short message to the user in a separate small window. The dialog box contains the text
given as a parameter to the alert() method and a button labelled OK.
d. window.confirm(): This method returns true if OK is pressed and false if Cancel is pressed.
e. parseInt(): parseInt() method converts a string value into integers (numbers without decimal places).
f. ParseFloat(): parseFloat() method converts a string value into floating numbers (numbers with
decimal values).
Q3. What is the object model in JavaScript.
Ans: Like most other programming languages of its generation, JavaScript is also characterized by the
Object Model. This means that you think about your JavaScript program in terms of the objects you want
to work with. For programming purposes, the browser window, the HTML document, forms, etc. are the
objects which in turn are formed of other objects such as Text Boxes and Radio buttons.