Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

GOLLIS UNIVERSITY

Course: Web Development II

Lecture Five

Presented by:
Sahardiid Ahmed Ali.
Chapter 3
Java Script: Introduction To Scripting

Chapter 3 Slide 2
Objectives
At the End of the lesson student should be able to:-
 What is Script?.
 Types of Script.
 What is JavaScript?.
 Features of JavaScript.
 Different between Scripting Languages and Programming
Languages.
 Where to Write JavaScript code
 Display statements in JavaScript
 Advantage and Disadvantage of Scripting Language.
 Several Examples of JavaScript.
Chapter 3 Slide 3
What is Script?
The term "Scripting Language" is also used loosely to refer
to dynamic high-level general-purpose languages such as
JavaScript-VBScript -Perl and Python.

 A script or scripting language is a computer language with a


series of commands within a file that is capable of being
executed without being compiled. Good examples of server-
side scripting languages include Perl, PHP, and Python.

Scripting Language are becoming more popular due to the


emergence of web-based applications.

Chapter 3 Slide 4
Types of Scripts

Scripts are classified into the fallowing two types:

1. Client Side Scripts.


2. Server Side Scripts.

Chapter 3
Slide 5
Client-side Script

1.Client Side Scripts


The scrip which is running the browser is called client side
scripting.

Client-side scripting is executed by a browser.


Example:-
Live Script
JavaScript
JQuery(JS Lib.)

Chapter 3
Slide 6
Server Side Script

2.Server Side Scripts


The script which is running within the web server is
called as server side scripting.
Server-side scripting is executed by a web server;
Example:-
ASP==>IIS(Internet Information Services)
PHP==>Apache

Chapter 3
Slide 7
Major advantage of scripting language:

1. Easy to learn and use.


2. Minimum programming knowledge or experienced
required.
3. Allow complex tasks to be performed in relatively
few steps.

Chapter 3
Slide 8
Major Disadvantage of Scripting Languages

1. In some cases it can be exploited for malicious


purpose (Security issues).
2. Not always able to work across different browsers.

Chapter 3
Slide 9
What is JavaScript?

JavaScript is a scripting language that is a light weight


Programming language that is interpreted by the
browser engine when web page is load.
JavaScript was created by Brendan Eich at Netscape
and was first introduced in December 1995 under
the name of Live Script.
JavaScript's official name is ECMA Script(European
Computer Manufacturer's Association)
International Organization

Chapter 3
Slide 10
Features of JavaScript

1. Generating HTML code on the Fly without accessing the


web server.
2. JavaScript can live by it self ,JavaScript is executed on the
client side.
3. Make your web pages responsive.
4. Detecting the user's browser .OS.Screen size ,etc.
5. Create cookies.
6. Validate web form data

Chapter 3
Slide 11
7. Automatically change a formatted date on a web page
8.Giving the user more control over the browser.
9. Handling dates and time.
10. Support for objects.

Chapter 3
Slide 12
Difference between Scripting Languages and
Programming Languages

Scripting Languages:-
1.Interpreted based(Read line by line).
2.Implicit Declaration of data types.

Ex. var x=100;


Var str="Sahardiid";
Var Y=100.7;

Chapter 3
Slide 13
Programming Languages:-

1.Compiler Based
2.Explicit Declaration of data types
Int x=100;
Float y=20.7;
String z="Sahardiid";
3.Rich Support for Application Development
4.Rich Support for Graphics Design or Games Development
5.Difficult to integrate with other technologies

Chapter 3
Slide 14
Why Study JavaScript

JavaScript is one of the 3 languages  all web developers must


be learn:

  1. HTML to define the content of web pages


   2. CSS to specify the layout of web pages
   3. JavaScript to program the behavior of web pages

Chapter 3
Slide 15
Where to Write Java Script

There are two area:-


1. Between open and close head
2. Between open and close Body

Chapter 3
Slide 16
Display statements in JavaScript

There are the fallowing display elements:-


1. Document.write ();
2. Document.writeln();
3. Window.alert();
4. Alert();
5. Window.print();
6. Console.log();

Chapter 3
Slide 17
Statements

JavaScript Statement ends with semicolon (;)


Every statement ends with a semicolon (also known as
the statement terminator).

Chapter 3
Slide 18
Example 01

<html>
<head>
<Script language="JavaScript">
document.writeln("Welcome to JavaScript ");
</script>
</head>
<body>
</body>
</html>

Chapter 3
Slide 19
Example 02
<html>
<head>
<title>JavaScript Example 02 </title>
</head>
<body>
<script language="JavaScript">
alert("Welcome to JavaScript");
</script>
</body>
</html>
Chapter 3
Slide 20
Using break Line <Br/>
<html>
<head>
<script type language="JavaScript">
document.writeln("Welcome to JavaScript");
Example 03 document.write('<br/>');
document.writeln("Welcome Gollis University”);
</script>
</head>
<body>
</body>
</html>
Chapter 3
Slide 21
Document.writeln means have space between to string

<html>
<head>
<script type language="JavaScript">
Example 04
document.writeln("Welcome to JavaScript");
document.write("Welcome University of
Hargeisa");
</script>
</head>
<body>
</body>
</html>
Chapter 3
Slide 22
Use some Elements:-Selectors and Colors
<html>
<head>
<script type language="JavaScript">
document.writeln("<h1 style='color:blue'> Welcome to
JavaScript</h1>");
document.write("Welcome University of Hargeisa");
</script>
</head>
<body>
</body>
</html>
Chapter 3
Slide 23
Use some Elements: Font-family
<html>
<head>
<script type language="JavaScript">
document.writeln("<h1 style='color:blue; font-
family:Tahoma'> Welcome to
JavaScript</h1>");
document.write("Welcome University of
Hargeisa");
</script>
</head>
<body>
</body>
Chapter 3 </html>
Slide 24
Example 05
<html> Use some Elements:-Selectors
<head>
<title>A First Program in JavaScript</title>
<script type ="text/javaScript">
document.writeln("<h1>Welcome to JavaScript
Programming!</h1>" );
</script>
</head>
<body>
</body>
</html>

Chapter 3
Slide 25
<html>
<head>
<title>A First Program in JavaScript</title>
<script language= "JavaScript">
document.writeln("<h1>Welcome to JavaScript
Example Programming!</h1>" );
</script>
</head>
<body>
</body>
</html>

Chapter 3
Slide 26
How to use Strings in JavaScript

The browser’s JavaScript interpreter to perform an action,


namely, to display in the web page the string of characters
contained between the double quotation (") marks (also called
a string literal).

Individual white-space characters between words in a string


are not ignored by the browser.

browsers ignore leading white-space characters (i.e., white


space at the beginning of a string).

Chapter 3
Slide 27
Notice:

Strings in JavaScript can be enclosed in either double


quotation marks (") or single quotation marks (').

Chapter 3
Slide 28
Any Question??
Thanks

You might also like