Professional Documents
Culture Documents
Delhi Public School Soft Lesson Plan - Class Vi Chapter 3 Javascript in HTML Document
Delhi Public School Soft Lesson Plan - Class Vi Chapter 3 Javascript in HTML Document
Introduction
To add functionality to your web page you need a scripting language. JavaScript is one of the most
popular scripting languages of the Internet. It works in all major browsers such as Internet Explorer,
Firefox, Chrome, Opera and Safari. JavaScript is a scripting language with very simple syntax.It is
used to add interactivity to your web pages.
JavaScript statements can be included in HTML documents by enclosing the statements between
opening and closing<SCRIPT>tag.
The section between opening<SCRIPT> and closing</SCRIPT>tag is called script block. For
example:
<SCRIPT language=”JavaScript”>
…..
[JavaScript statements]
…..
</SCRIPT>
For example:
…..
[JavaScript statements]
…..
</SCRIPT>
JavaScript is an object-based language based on prototypes, rather than being class-based. Because of
this different basis, it can be less apparent how JavaScript allows you to create hierarchies of objects
and to have inheritance of properties and their values.
document.write()Method
The document.write() method is used for displaying the text on the browser window. It uses an
object called document, which refers to the content document on the browser.
<html>
<body>
<script language="javascript">
</script>
</body>
</html>
JavaScript Variables
JavaScript has variables that you can declare with the optional var keyword
Variables declared within a function are local to that function
Variables declared outside of any function are global variables
JavaScript Operators
Arithmetic (+, - , * , /, %)
Assignment (= , += , -= , *= /= , %= , ++, --)
Logical (&&, ||, !)
Comparison (, <= , >= , ==)
If a document contain frames (<iframe> tags), the browser creates one window object for the HTML
document, and one additional window object for each frame.
parseInt() and parseFloat() Methods in Javascript are used to convert to a non-number values into
numbers.parseInt() is for converting a non integer number to an int and parseFloat() is for converting
string until the first decimal point.
Example:
Question-Answers
Ans.JavaScript is a scripting language with a very simple syntax.It is used to add interactivity to
your web page.Javascript is set to execute when you want some changes to be reflected on the
web page.
Ans. parseInt() and parseFloat() Methods in Javascript are used to convert to a non-number
values into numbers.parseInt() is for converting a non integer number to an int and parseFloat() is
for converting string until the first decimal point.
Ans. JavaScript works in all major browsers such as Internet Explorer, Firefox, Chrome, Opera
and Safari.
*******************************