Docsity

Understanding Client-Side and Server-Side Scripting with JavaScript, Lecture notes of Web Design and Development

Partial preview of the text

Download Understanding Client-Side and Server-Side Scripting with JavaScript and more Lecture notes Web Design and Development in PDF only on Docsity!

Client Side Concepts

Using JavaScript -

January 13, 2020

Internet Programming

(CoSc3031)

Outline

1. Introduction

2. Basic Language Features: variables,

expressions, operators, statements

3. Javascript: Basic syntax and flow control

statements

4. Javascript : Forms and Functions

5. Javascript : Arrays and Objects

6. Javascript :Error and Event Handling

7. Javascript :Document Object Model (DOM)

8. Advanced concepts of Client-side scripting

Internet Programming

Internet Programming

Introduction to Scripting

 (^) Scripting Languages are mainly used to build the programming environment in HTML document  (^) Make Web pages dynamic and interactive.  (^) Some languages are : VBScript, JavaScript, Jscript, PHP, Python, Active Server Page(ASP), Java Server Page(JSP), Java Server Face(JSF), Common Gateway Interface(CGI), Perl , Java Servlets, etc.  (^) Browser Includes Scripting Interpreter  (^) Choosing a Scripting Language  (^) Browser compatibility  (^) Programmer familiarity  (^) Scripts can be executed on client or the server.

Introduction to scripting &

classification

1. Client-Side Scripting  (^) Client-side scripting enables interaction within a webpage. The code required to process user-input is downloaded and compiled by the browser or plug-in. 

It is a language that runs on a local browser (on

the client tier) instead of on a Web server (on

the processing tier)

 (^) An example of a client-side interaction is a rollover (typically triggered when choosing a navigation option).  (^) Web siteStatic Web site, limited interactivity Internet Programming

Internet Programming

Scripting language :Comparison

Client Side Scripting Server Side Scripting Runs on the user’s computer i.e. Browser interprets the script. Runs on the Web server Source code is visible to the user. Source code is not visible to the user because the output of server side program is an HTML page. Used for validations and functionality for the user events. Used for business logic and data access from the database. The pages are created dynamically. Depends on the browser and version. E.g.. JavaScript , VBscript etc Not depend on the client, any server side technology can be used. E.g. PHP , Python, Ruby, JSP, Perl etc 7

Client-Side Programming

 (^) Client-side scripts are placed within an HTML document in the user’s web browser rather than the web server to allow greater interactivity in a document. For example – client-side scripting could check the user’s form for errors before submitting it  (^) Enables web pages to change content according to user input and other variables, including the time of day. Can also be stored in a separate file that is referenced to the documents that use it.  (^) HTML is good for developing static pages(static web sites)  (^) can specify text/image layout, presentation, links, …  (^) Web page looks the same each time it is accessed  (^) in order to develop interactive/reactive pages, must integrate programming in some form or another Internet Programming

Applications of Client-Side Scripting

 Web page responds to or reacts directly with user interaction through HTML Form elements , eg, input fields, text areas, buttons, radio buttons, etc.  Distributing a small amount of database information directly from the Web page  (^) You need to control the Web page appearance based on user selections  (^) You want to preprocess data before submission to the server. Internet Programming

Server-Side Programs  (^) a user must be connected to the Web server to run the server-side script  (^) only the programmer can create or alter the script  (^) the system administrator has to be concerned about users continually accessing the server and potentially overloading the system  (^) A server-side language is one that runs on the Web server. Examples: PHP, Python, JSP, ASP, CGI, Perl, … Internet Programming

Introduction to JavaScript

 (^) A client-side scripting language that allows Web page authors to develop interactive Web pages and sites  JavaScript is considered a scripting language because it is interpreted by the browser at runtime (when the web page is actually opened) rather than compiled and stored on your computer.  It provides a computational capability in web documents.  (^) It is used in creating, accessing, modifying a document.  (^) Used in most Web browsers including Firefox and Internet Explorer Internet Programming

Introduction to JavaScript …

 JavaScript scripting language  (^) Easy Program development  (^) Easy Program control structure  (^) Client-side scripting enhances functionality and appearance  (^) Makes pages more dynamic and interactive  (^) Pages can produce immediate response without contacting a server  (^) Customization is possible on the basis of users’ explicit and implicit input  (^) Browser has to have a built-in (JavaScript) interpreter Internet Programming

What can JavaScript do?  Giving the user more control over the browser  (^) Detecting the user's browser, OS, screen size, etc.  (^) Performing simple computations on the client side  Validating the user's input  (^) Handling Events, Errors and exceptions  (^) Generating HTML pages on-the-fly without accessing the Web server. Internet Programming

Client-side Script can’t ...

 Set or retrieve browser preferences  (^) launch an application on client computer  (^) read or write files on client computer  (^) Extract text content from HTML page  Do much of anything on server computer including accessing a database Internet Programming

Internet Programming

Features of JavaScript

 (^) Designed for programming user events JavaScript is a lightweight, interpreted language  (^) Embedded within HTML, Complementary to and integrated with HTML.  (^) Minimal Syntax- Easy to learn  (^) Mainly used for client side scripting because it is supported by all the browsers.  (^) Open source-free  (^) Platform Independence/ Architecture Neutral

Internet Programming

JavaScript – lexical structure

 JavaScript is object based, action-oriented, &object orientation.  (^) JavaScript is case sensitive.  (^) A semicolon ends a JavaScript statement  (^) C-based language developed by Netscape  Comments  (^) Supports single line comments using //  (^) and multi line comments using /…../