Web Technology

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Introduction

Web technology is defined as the technology that primarily deals with how
to save web information securely in webservers and how to retrieve
information from these servers using different internet based tool and
techniques. It is the methods by which computers communicate with each
other through the use of markup languages and multimedia packages.

Prepared by: Govind Bhat


Server Side and Client Side Scripting
Server-side scripting is a technique used in web development which involves employing scripts on a web
server which produces a response customized for each user's (client's) request to the website. Basically,
they’re utilized to make dynamic pages. It can also gain access to the web server’s file system.
A web server is a server-side environment that runs on a programming language.
Scripts can be developed in any of the existing server-side scripting languages. It is used to retrieve and
generate dynamic page content.

Client-side scripting can be utilized to make websites more interactive. It is typically used at the front
end, which is where users can view the web page using the browser. In client side scripting the scripts are
executed by browsers without connecting the server. The most important functions of scripting on the
client side are listed below:
• To retrieve information from a web browser or the user's screen.
• To personalize the web page without having to load it again.
• Client-side scripting can be used to verify credentials. If the user has entered incorrect details when
logging in, the web page will display an error message on the user's machine and will not submit data
to the website server.

Prepared by: Govind Bhat


Server Side and Client Side Scripting

Prepared by: Govind Bhat


Server Side and Client Side Scripting

Prepared by: Govind Bhat


Introduction of Internet Technology
The Internet is defined as a global system of interconnection of millions of networks around the world
that use common standard rules, commonly known as TCP/IP suite for exchanging the information and
resources.

Fig: A logical view of internet

Prepared by: Govind Bhat


Introduction of Internet Technology
WWW or web is a global platform to access the information, resources from webpages and HTTP is the
common rules or protocol that allows to transfer webpages with links from one computer to another on
the Internet.

Prepared by: Govind Bhat


Java Script Fundamental
• JavaScript(JS) is one of the most popular scripting programming language.

• It is a case sensitive interpreted programming language with object oriented capabilities.

• It is light weight and mostly used to develop dynamic websites.

• JavaScript was created in 10 days in May 1995 by Brendan Eich.

• The original name of JavaScript was Mocha( name chosen by founder of Netscape).

• In September 1995, name changed to LiveScript.

• Again in December 1995, name changed to JavaScript.

• European Computer Manufactures Association (ECMA) standardized JavaScript as ECMA-262.

• JavaScript is a client side scripting language.

Prepared by: Govind Bhat


Major Features of JavaScript
• It is a standard scripting language and supported by most of the browsers.

• It is light weight and efficient interpreted programming language.

• It s complementary to and integrated with HTML and Java.

• It is object-oriented event driven programming language.

• It is open source and cross platform(independent to OS).

Prepared by: Govind Bhat


Importance of JavaScript
• It is designed for solving client-side application with prompt responds.

• It can dynamically modify webpages as per requirements.

• It can validate and respond user’s input.

• It can be used to create cookies.

• It does not require any interaction to web server while processing scripts on web browser.

Prepared by: Govind Bhat


Adding JavaScript to HTML page

<script language=“Javascript” type=“text/javascript”>…………..</script>

Or

<script type=“text/javascript”>………………………..</script>

Script can be placed either inside the <HEAD> tags or <BODY>tags. We can embed any number
of scripts in a webpage. In the <HEAD> tags, the scripts are run before the page displayed and in
the <BODY>tags, scripts are run as the page is displayed. Mostly, the functions and variables are
defined in the <HEAD>tags and these functions are used by the scripts within the <BODY> tags.
Scripts also can be stored in external file with file extension .js and such scripts can also be
loaded from external file by using the following examples.

Prepared by: Govind Bhat


Adding JavaScript to HTML page

Example of Internal Scripts

<!DOCTYPE html>
<html>
<head>
<title>Hello World in JavaScript</title>
</head>
<body>
<script type="text/javascript">
document.write("Hello World");
</script>
</body>
</html>

Prepared by: Govind Bhat


Adding JavaScript to HTML page
Example of Internal Scripts

Instead of using function document.write(), we can also use function getElementById(). This
feature helps to access particular tag in HTML using tag id.

<!DOCTYPE html>
<html>
<head>
<title>Hello World in JavaScript</title>
</head>
<body>
<p Id=“eg”></P>
<script type="text/javascript">
document.getElementById(“eg”).innerHTML=“Hello World”;
</script>
</body></html>

Prepared by: Govind Bhat


Adding JavaScript to HTML page
Example of External Scripts

<script src=“eg.js”>

</script>

Prepared by: Govind Bhat


Simple User Interaction Functions
JavaScript provides three built-in functions to do simple user interaction.

• alert(msg): It helps to make alerts to the user that something has happened.

Example: alert(“Thanks for visiting the page.”);

• confirm(msg): It helps to asks the user to confirm or cancel something.

Example: confirm(“Do you want to delete the file?”);

• prompt(msg, default value): It helps to ask user to enter some text value.

Example: prompt(“Enter your name”, “John”);

Prepared by: Govind Bhat


Simple User Interaction Functions
Example:

<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">
document.write("Example of alert, confirm and prompt:");
alert("Thanks for visiting my web page.");
confirm("Do you want to delete the file?");
prompt("Enter your Name:");
</script>
</body>
</html>

Prepared by: Govind Bhat


Comments in JavaScript
Comments are used to write remarks in JavaScript. JavaScript defines two types of comments:

Single line comments: //This is an example of single line comment

Multi line comments: /*This is an example of

multi line comment*/

Prepared by: Govind Bhat


JavaScript Data Types
Every programming language has set of data types. JavaScript provides three basic types ;

1. Numbers: -1, -25, 0, 1, 105, 3.1415 etc.

2. Strings: “A”, “ABC”, “12345”, “JavaScript”

3. Boolean: true or false, 1 or 0

Prepared by: Govind Bhat


Variables
• A variables defines a unique name that represents a unit of memory space to store data on
computer.
• Every variable name must start with character or underscore and it must not be space and
JavaScript keywords.
• A variable should declare before using it.
• A variable is declared by using the keyword var followed by semicolon.
• A value is assigned to the respective variable by using assignment operator(i.e. =).
Syntax: var variable_name;

Example:
Var a;
Var roll_number=1;
Var name;

Prepared by: Govind Bhat


Variables
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">

var x=100;
document.write("The value of x="+x);

</script>
</body>
</html>

Prepared by: Govind Bhat


Operators
An operator is a specific symbol in programming which is used to carry out some specific
calculation or comparison. JavaScript supports the following types of operators:
• Arithmetic operators
• Comparison operators
• Logical operators
• Assignment operators
• Ternary(or Conditional) operators

Prepared by: Govind Bhat


Operators
1. Arithmetic Operators:

Operator Description
+ Used for adding numbers and concatenates strings.
- Used for subtracting numbers.
* Used for numbers multiplication.
/ Used for numbers division.
% Used for numbers remainder division.
++ Used for incrementing the value of variable by 1.
-- Used for decrementing the value of variable by 1.

Prepared by: Govind Bhat


Operators
1. Arithmetic Operators:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">
var a=25;
var b=10;
var result;
document.write("a=25<br>b=25");
result=a+b;
document.write("<br>a+b="+result);
</script>
</body>
</html>
Prepared by: Govind Bhat
Operators
2. Comparison Operators:
Comparison operators are Boolean operators, so they give Boolean result: true or false.

Operator Description
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to

Prepared by: Govind Bhat


Operators
2. Comparison Operators:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">
var a=25;
var b=10;
document.write("a=25<br>b=10");
document.write("<br> a < b:");
document.write(a<b);
</script>
</body>
</html>

Prepared by: Govind Bhat


Operators
3. Logical Operators:
Logical operators are Boolean operators, so they give Boolean result either true or false.

Operator Description
|| Logical OR
&& Logical AND
! Logical NOT

Prepared by: Govind Bhat


Operators
3. Logical Operators:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">
var a=true;
var b=false;
document.write("a=true <br> b=false");
document.write("<br> a && b:");
document.write(a&&b);
</script>
</body>
</html>

Prepared by: Govind Bhat


Operators
4. Assignment Operators:
Assignment operator used to assign or store value to a variable.

Operator Description
= Assignment
+= Add and assignment (Eg. a+=5 //a=a+5)
-= Subtract and assignment
*= Multiply and assignment
/= Divide and assignment
%= Modulus divide and assignment

Prepared by: Govind Bhat


Operators
4. Assignment Operators:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">
var a=10;
document.write("<br>Value of a=>"+a);
a+=5;
document.write("<br> Value of (a+=5)=>"+a);
</script>
</body>
</html>

Prepared by: Govind Bhat


Operators
5. Ternary Operators(Conditional):
Conditional operator is also known as ternary operator helps to check the Boolean
values that is true or false. It is same as if else statement.
Syntax: exp1?exp2:exp3;
Example: a>b?a:b;

Prepared by: Govind Bhat


Operators
5. Ternary Operators(Conditional):
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of User Interaction Functions</title>
</head>
<body>
<script type="text/javascript">
var a=10,b=20;
var max;
document.write("<br>a=10<br>b=20");
max=a>b?a:b;
document.write("<br>The maximum number is="+max);
</script>
</body>
</html>

Prepared by: Govind Bhat

You might also like