0% found this document useful (0 votes)
0 views3 pages

Chapter 5 - JavaScript in HTML Documents

The document outlines Chapter 5 of a Computer Science curriculum for Class 8, focusing on JavaScript within HTML documents. It includes JavaScript statements for string concatenation, variable declaration, and displaying dialog boxes, along with explanations of various JavaScript methods and operators. Additionally, it emphasizes the object model in JavaScript and provides instructions for activities and lab work.

Uploaded by

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

Chapter 5 - JavaScript in HTML Documents

The document outlines Chapter 5 of a Computer Science curriculum for Class 8, focusing on JavaScript within HTML documents. It includes JavaScript statements for string concatenation, variable declaration, and displaying dialog boxes, along with explanations of various JavaScript methods and operators. Additionally, it emphasizes the object model in JavaScript and provides instructions for activities and lab work.

Uploaded by

Rivaan Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

The Sanskaar Valley School

Class 8 – Computer Science

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.

Q1. Give JavaScript statements to perform the following tasks:


a. Concatenating (joining) two strings: “Click” and “Start”.
<HTML>
<HEAD>
<BODY><
SCRIPT language = “JavaScript”>
var str1, str2
str1= “Click”
str2= “Start”
document.write(str1+str2+“ </Br>”); //to add a space in between
document.write(str1+ “ “ +str2);
</SCRIPT>
</BODY>
</HEAD>
</HTML>

b. Using single line and multiple line comments.

Single line comments:


// This is comment line 1
Multiple line comments:
/* This is comment line 1
This is comment line 2 */
c. Declaring four variables: length, breadth, height, and volume.
var length, breadth, height, volume

d. Display a confirm dialog box with the message “Plant more trees”.

<HTML>

<BODY>

<SCRIPT language=“JavaScript”>

var reply = confirm (“Plant more trees”)

document.write(reply);

</SCRIPT>

</BODY>

</HTML>

Q2. Describe the use of the following methods in JavaScript:


a. document.write(): The document.write() method is used for displaying the text on the browser
window. It uses an object called document, which refers to the current document on the browser
window.

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.

Q4. Discuss various types of operators in JavaScript.


Ans: Various types of operators in JavaScript are discussed below.
a. Arithmetic operators: These operators are used to perform arithmetic calculations using variables
or constants.
b. Comparison operators: These operators are used to test if two variables relate to each other in
the specified way.
c. Logical operators: These operators perform logical operations on variables.
d. String operator: A string is a set of characters. To join two or more string values together, you use
the plus ‘+’ operator. This is also known as string concatenation operator.

✓ Do Activity given on Page no 91 and 100.


✓ Lab Work on page no 104
(paste in notebook)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy