Javascript - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Javascript

Description:

BODY bgcolor = 'Green' onload = 'greetings()' Javascript event handlers ... INPUT TYPE = 'Button' Value = 'newWindow' onclick = 'window.open( http://ww.yahoo.com' ... – PowerPoint PPT presentation

Number of Views:170
Avg rating:3.0/5.0
Slides: 17
Provided by: facultyCa
Category:

less

Transcript and Presenter's Notes

Title: Javascript


1
Javascript
  • An introduction

2
What is javascript ?
  • A programming language (C like syntax)
  • Javascript code is part of an html page
  • Javascript runs on the client side, inside a
    browser
  • Javascript is interpreted (by the browser)
  • Open language, no need to buy anything

3
What can you do with javascript?
  • Scrolling messages
  • Animations, dynamic images
  • check form data locally
  • Pop-up windows
  • Interaction with user (executed locally, without
    a CGI script going to the server and back)

4
Script tag
  • To use javascript, you need to tell the browser
    that a script language is being used
  • Typically in between ltheadgt and lt/headgt
  • ltscript language Javascriptgt
  • // Some javascript code here
  • lt/scriptgt

5
Javascript as a programming language
  • Identifiers (same as C)
  • Variables (case sensitive)
  • Literals
  • Operators (, -, , , )
  • Functions
  • if, switch, while, for, do while, ..
  • Some OOP

6
Variables
  • Syntax var is a keyword
  • var identifyer
  • Examples
  • var width 3
  • var browserType Nestcape
  • var quotation \To be or not to be\.

7
Some built-in methods
  • write() method
  • Is associated with the Document object and is
    used to write text to a web page (that text
    should be HTML code)
  • alert() method
  • Is used to display messages in a dialog box

8
Functions
  • function definition
  • function Greetings( )
  • alert( Hello there )
  • function Greetings2( message )
  • alert( message )

9
Objects
  • Javascript uses objects but is not a full blown
    OOP language
  • Objects, dot notation, methods, arguments, ..
  • There are some built-in objects Date, Arrays,
    windows, forms, items on the form (checkboxes,
    ..)

10
Small portion of object hierarchy in Javascript
11
Existing objects
  • With javascript, we can access the attributes of
    these objects (background color of the web page,
    text inside a text field, )

12
Events
  • Most interaction is event driven
  • Examples clicking on a button, entering data,
    clicking on a checkbox or a radio button, ..
  • Handlers, written by programmers, enable to react
    to events

13
Event handlers
  • Examples of event handlers
  • onKeyDown, onKeyUp, onLoad, onMouseDown,
    onMouseUp, onMouseOver, onResize, onReset,
    onSelect, onSubmit, onUnload,

14
Javascript event handlers
  • When an event happens, we can execute some
    javascript
  • ltINPUT TYPE Button Value Yellow onclick
    document.bgColor Yellow gt
  • We can also call a function when an event happens
  • ltBODY bgcolor Green onload greetings() gt

15
Javascript event handlers
  • When an event happens, we can execute some
    javascript
  • To go to another web page in a new window
  • ltINPUT TYPE Button Value newWindow
    onclick window.open(http//ww.yahoo.com)gt

16
Javascript short summaryWhat is javascript for?
  • Local processing of data and user generated
    events
  • Some fun stuff
  • AJAX
Write a Comment
User Comments (0)
About PowerShow.com