The document discusses client-side scripting with JavaScript. It defines what a script is and notes that JavaScript is the main scripting language used for client-side scripting in web browsers. It describes how JavaScript can be used to add interactivity to HTML pages by dynamically updating content. The document also provides details on JavaScript statements, variables, functions, events, and how to access and modify the DOM using the document object model.
CLIENT SIDE SCRIPTINGWITH
JAVASCRIPT
Prepared By:
Bansari Shah
EN. NO.:150410107098
TY CE-2(Batch â B)
2.
âA script isa program that automates the execution of
tasks which could alternatively be executed one-by-one
by a human operator.â
What is a Script?
3.
A scripting languageis a programming language that
supports the writing of scripts.
Scripting Languages
4.
īĒ The server-sidescripting comprises all the scripts that
are executed on the server.
īĒ Adopted technologies: Perl, PHP, ColdFusion, XSTL,
etc.
īĒ The code is not visible to the client.
Server-side Scripting
6.
īĒ The client-sidescripting comprises all the scripts that
are executed on the browser.
īĒ The scripting derives from the event-based
programming that is typical of user interfaces.
īĒ Adopted technologies: JavaScript, VBScript.
Client-side Scripting
8.
Client-side Scripting
ADVANTAGES
īĒ TheWeb browser uses its own
resources, and eases the
burden on the servlet.
īĒ It has fewer features than
server side scripting
DISADVANTAGES
īĒ Code is usually visible.
īĒ Code is probably modifiable.
īĒ Local files and databases canât
be accessed. (as they are
stored on the server)
9.
īĒ JavaScript isthe language of the web browser.
īĒ JavaScript was originally called Live Script, and was
developed by Netscape Communications.
JavaScript
10.
īĒ JavaScript isdesigned to add interactivity to HTML pages
īĒ JavaScript :
īĒ consists of lines of interpretable computer code
īĒ gives HTML designers a programming tool
īĒ is usually embedded directly into HTML pages.
īĒ allows to put dynamic text into an HTML page
īĒ Java and JavaScript are two completely different
languages in both concept and design
JavaScript
11.
īĒ JavaScript isused in millions of web pages
īĒ to improve the design
īĒ to validate forms
īĒ to detect browsers
īĒ to create cookies
īĒ JavaScript can react to events and can be used to validate data
and to create cookies
īĒ Is the most popular scripting language in all major browsers e.g.
īĒ Internet Explorer
īĒ Mozilla
īĒ Firefox
īĒ Netscape
īĒ Opera
JavaScript
12.
<html> Tells wherethe JavaScript starts
<body>
<script type=âtext/javascriptâ>
document.write(âHello World!â);
</script> Commands for writing output to a page
</body>
</html> Tells where the JavaScript ends
This code produce the output on an HTML page: Hello World!
JavaScript and HTML page
īĒ JavaScript statementsare
īĒ codes to be executed by the browser
īĒ tells the browser what to do
īĒ commands to the browser
īĒ add semicolons at the end
īĒ can be grouped together into blocks using curly
brackets
īĒ JavaScript comments make the code more readable
īĒ Single line comments start with //
īĒ Multi line comments start with /* and end with */
Statements and Comments
15.
īĒ JavaScript Variablesare containers for storing
information e.g. x=15; length=60.10
īĒ It hold values or expressions
īĒ can hold a text value like in name=âmultimediaâ
īĒ var statement can declare JavaScript variables: var x;
var name;
īĒ Variable names are case sensitive i.e. âmyVarâ is not
the same as âmyvarâ
īĒ must begin with a letter or the underscore character
JavaScript Variables
16.
īĒ JavaScript Functions
ī§Can be called with the function name
ī§ Can also be executed by an event
ī§ Can have parameters and return statement
* Events
ī§ are actions that can be detected e.g. OnMouseOver,
onMouseOut etc.
ī§ are normally associated with functions
ī§ <input type="text" size="30" id="email"
onChange="checkEmail()">
JavaScript Functions and Events
17.
* Javascript actionsmay be triggered from events, e.g. changes on
form fields or a submit button being clicked:
ī§ onfocus = Form field gets focus (validation)
ī§ onblur= Form field looses focus (validation)
ī§ onchange= Content of a field changes (validation)
ī§ onselect= Text is selected
ī§ onmouseover= Mouse moves over a link (animated buttons)
ī§ onmouseout= Mouse moves out of a link (animated âĻ)
ī§ onclick= Mouse clicks an object
ī§ onload= Page is finished loading (initial actions, info,)
ī§ onSubmit= Submit button is clicked (validation etc.)
JavaScript: Events
18.
īĒ The documentobject represents the whole html
document.
īĒ When html document is loaded in the browser, it
becomes a document object. It is the root
element that represents the html document. It has
properties and methods. By the help of document
object, we can add dynamic content to our web page.
Document Object Model
īĒ We canaccess and change the contents of document
by its methods.
īĒ The important methods of document object are as
follows:
Methods of document object
21.
<script type="text/javascript">
function printvalue(){
varname=document.form1.name.value;
alert("Welcome: "+name);
}
</script>
<form name="form1">
Enter Name:<input type="text" name="name"/>
<input type="button" onclick="printvalue()" value="print name"/>
</form>
Accessing field value by document
object