CSC 330 E-Commerce
Teacher
Ahmed Mumtaz Mustehsan
GM-IT CIIT Islamabad
Virtual Campus, CIIT
COMSATS Institute of Information Technology
T2-Lecture-6x
JavaScript
Part - I
For Lecture Material/Slides Thanks to: www.w3schools.com
Synopsis
Introduction
JavaScript
Where To
JavaScript Output
JavaScript Syntax
JavaScript Statements
JavaScript Comments
JavaScript Variables
JavaScript Data Type
3
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
Introduction
Introduction
JavaScript
is the programming language of the Web.
All modern HTML pages are using JavaScript.
JavaScript is one of 3 languages that all web
developers MUST learn:
HTML to define the content of web pages
CSS to specify the layout of web pages
JavaScript to program the behavior of web pages
JavaScript is the most popular programming
language in the world.
It is the language for HTML, for the Web, for
computers, servers, laptops, tablets and smart
phones.
5
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
Where To place JavaScript
In
HTML, Java Scripts must be inserted between
tags.
The lines between contain
the JavaScript code:
Java Scripts can be put in the and in the
section of an HTML page.
6
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
Example
Just take it for a fact, that the browser will interpret the code
between the tags as JavaScript.
Old examples may have type="text/javascript" in the
My Web Page
A Paragraph
Demo!!!
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
110
JavaScript in
In this example, a JavaScript function is placed in the section of
an HTML page.
The function is invoked (called) when a button is clicked:
My Web Page
A Paragraph
◦Demo2!!!
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
111
External JavaScripts
Scripts
can also be placed in external files.
External scripts are practical when the same code is
used in many different web pages.
External JavaScript files have the file extension .js.
To use an external script, put the name of the script
file in the source (src) attribute of the
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
112
External JavaScripts…
You
can place an external script reference in
or as you like.
The script will behave as if it was located exactly
where you put the reference in the HTML document.
External scripts cannot contain
T2-Lecture-6
Ahmed Mumtaz Mustehsan
www.w3schools.com
116
Manipulating HTML Elements…
The
JavaScript statement (inside the