SlideShare a Scribd company logo
JavaScript - a Brief Introduction


           IMI PRINCE
     www.newsvelley.blogspot.com
What is JavaScript

• Object based (not object oriented)
  programming language
  – very limited object creation
  – a set of pre-defined objects associated with
     • HTML document structure
        – many HTML tags constitute JS Objects
     • Browser functionality
        – provides a limited API to Browser functionality
Where did it come from
• Originally called LiveScript at Netscape
   – started out to be a server side scripting language for
     providing database connectivity and dynamic HTML
     generation on Netscape Web Servers
   – Netscape decided it would be a good thing for their
     browsers and servers to speak the same language so it
     got included in Navigator
   – Netscape in alliance w/Sun jointly announced the
     language and its new name Java Script
   – Because of rapid acceptance by the web community
     Microsoft forced to include in IE Browser
Browser compatibility

• For the most part Java Script runs the same
  way in all popular browsers
• There are many areas where there are slight
  differences in how Java Script will run
• there will be a separate set of slides
  addressing these differences.
JavaScript…Java ?

• There is no relationship other than the fact
  that Java and JavaScript resemble each
  other (and C++) syntactically
• JavaScript is pretty much the de-facto
  standard for client-side scripting (Internet
  Explorer also provides VBScript & JScript)
• In Netscape browsers there is an API that
  allows JavaScript and Java applets
  embedded in the same page to converse
What can it be used for

• Some pretty amazing things….
  – Text animation
  – graphic animation
  – simple browser based application
  – HTML forms submission
  – client-side forms data validation (relieving the
    server of this task)
  – web site navigation
What do I need to get started

• A web browser
  – Netscape Navigator 4.x or later
  – MS Internet Explorer 3.x or later
• A text Editor
  – Wordpad/Notepad
  – Vi, Emacs
Process

•   Open your text editor
•   create a file containing html and Javascript
•   save as text file with file type .htm or .html
•   open your browser
•   click on file, open file
    – locate the file you just created
• open file in browser
Putting JavaScript into your HTML

• in an external file
   – collect commonly used functions together into
     external function libraries on the server
      • added benefit of privacy from curious users
• in-line with your HTML
• as an expression for an HTML tag attribute
• within some HTML tags as Event Handlers
<SCRIPT>…</SCRIPT>
• <SCRIPT language=…. src=……></SCRIPT>
• The <SCRIPT> tag indicates to the browser the
  beginning of an embedded script; </SCRIPT>
  indicates the end of an embedded script.
• the “language” attribute indicates the script
  processor to be used
• the “src” attribute indicates the URL of a file on
  the server containing the script to be embedded
Scripts

• Since scripts are placed in line with with
  HTML older browsers will attempt to
  render them as text.
• To preclude this hide them in side of an
  HTML comment . <!--          -->
• for JavaScript comments use // or /* */
<SCRIPT>
•   <SCRIPT LANGUAGE=“JavaScript”>
•   <!-- start hiding code from old browsers>
•   Script
•   Code
•   Goes
•   Here
•   // Stop Hiding code -->
•   </SCRIPT>
Object Hierarchy

                                 window


                   history       document       location   link


 link    anchor         layer     form      applet     image        area



          text         radio      button     fileUpload    select

        textarea      checkbox     reset                   option

        password                  submit
Objects
• window - the current browser window
• window.history - the Netscape history list
• window.document - the html document currently in the
  browser client area
• window.location - the browser location field
• window.toolbar - the browser toolbar
• window.document.link - an array containing all of the
  links in the document
• window.document.anchor - an array of all the anchor
  points in the document
Objects (more…)
•   Window.document.layer - a named document layer
•   window.document.applet - a named java applet area
•   window.document.image- a named image tag
•   window.document.area - a named area
•   window.document.form - a named form or the default form
•   ect, ect
A few examples...
• window.location = “http://www.yahoo.com”
   – will take you to the specified URL (like a goto)
• window.history.back()
   – back() is a method on history
   – will be like clicking the back button in Nav 3
   – in Nav 4 will take you back to prev window
• window.history.goto(1)
   – takes you back to first URL in history array
The Object Model

• It is very important to understand the object
  model
• each object has its own properties, some of
  which are read only some of which you can
  set directly by assignment (as location)
• each object also has a set of behaviors
  called methods
Object Model

                              =                 Text Object
                                              HTML text tag
      B l u r ()
                   defaultValue
                      form
                      name         Select()

                       type
     focus()          value                   Red - gettable and settable



                     handleEvent
Object Event Handlers
• Most objects respond to asynchronous, user generated
  events through predefined event handlers that handle the
  event and transfer control to a user written event handling
  function
• Each object has particular events that they will respond to
• the way you specify an event handler is by adding an
  additional attribute to the HTML tag that specifies the
  particular handler
• <input name=bt1 type=button value=ok onClick=“acb();”>
Events
•   onAbort
•   onBlur
•   onChange
•   onClick
•   onError
•   onFocus
•   onLoad
•   onMouseOut
•   onMouseOver
•   onReset
•   onSelect
•   onSubmit
•   onUnload
onAbort

• Activated when a user aborts the loading of
  an image

    <img name=ball src=images/ball.gif onAbort=“alert(‘You missed a nice picture’)”>
onBlur

• Used with frame, select, text, textarea and
  window objects
• invoked when an object loses the focus
• use with select, text and textarea for data
  validation
onChange

• Used with select, text and textarea objects
• use instead of onBlur to validate only if a
  value has changed

   <form>
   Color: <select onChange=“processSelection()”>
   <option value=“R”>Red
   <option value=“G”>Green
   <option value=“B”>Blue
   </select>
   </form>
onClick

• Used with button, checkbox,link, radio,
  reset, and submit objects.

   <input type=button name=btn1 value=“Click Me” onClick=“alert(‘button was clicked’;” >
onError

• Used with image and window objects to
  invoke a handler if an error occurs while an
  image or window is loading.
• Setting window.onerror = null will prevent
  users from seeing JavaScript generated
  errors
onFocus

 • Used with frame, select, text, textarea and
   window objects.
 • Just the opposite of onBlur; i.e. invoked
   when the object gets focus.

<body bgcolor=“lightgrey” onBlur=“document.bgColor=‘black’ onFocus=“document.bgColor=‘white’” >
onLoad
• Used with window, frame and image objects (use
  with <body ….><frameset ….> and <img ...>)


     <img name=spinball src=images/spinball.gig onLoad=“startAnimation(this)”>
onMouseOut and onMouseOver

• Used with area and link objects
• user moves mouse off of an area or link
    <map name=flower>
    <area name=top coords=“0,0,200,300 href=“javascript:displayMessage()”
        onMouseOver=“self.status=‘when you see this message click your left mouse button’ ;
        return true”
        onMouseOut=“self.status = ‘’ ; return true”>
onReset

• Used with form objects



           <form onReset=“alert(‘the form has been reset’)” >
onSelect

• Used with text and textarea objects
• run some JavaScript whenever a user
  selects a piece of text in a text or textarea
  object
           <input type=text name=line onSelect=“showHelp()” >
onSubmit

• Use with form objects to run a handler
  whenever a form has been submitted.
• Useful to validate all fields prior to actual
  submission
onUnload

• Just like onLoad but the handler is run
  when the window/frame is exited

               <body onUnload=“cleanup()” >

More Related Content

What's hot (20)

Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Javascript event handler
Javascript event handlerJavascript event handler
Javascript event handler
Jesus Obenita Jr.
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
javascript objects
javascript objectsjavascript objects
javascript objects
Vijay Kalyan
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
Jalpesh Vasa
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
Dominic Arrojado
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
Java script
Java scriptJava script
Java script
Abhishek Kesharwani
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
Js: master prototypes
Js: master prototypesJs: master prototypes
Js: master prototypes
Barak Drechsler
 
Javascript
JavascriptJavascript
Javascript
guest03a6e6
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
Hassan Dar
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
Jeff Fox
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 

Viewers also liked (20)

Java script ppt
Java script pptJava script ppt
Java script ppt
The Health and Social Care Information Centre
 
Js ppt
Js pptJs ppt
Js ppt
Rakhi Thota
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Priya Goyal
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Bryan Basham
 
PhoneGap - JavaScript for Mobile Apps
PhoneGap - JavaScript for Mobile AppsPhoneGap - JavaScript for Mobile Apps
PhoneGap - JavaScript for Mobile Apps
Kentucky JavaScript Users Group
 
PhoneGap @ Javascript Directions
PhoneGap @ Javascript DirectionsPhoneGap @ Javascript Directions
PhoneGap @ Javascript Directions
Tiang Cheng
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
Frayosh Wadia
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to Titanium
Techday7
 
PhoneGap JavaScript API vs Native Components
PhoneGap JavaScript API vs Native ComponentsPhoneGap JavaScript API vs Native Components
PhoneGap JavaScript API vs Native Components
TechAhead
 
D3
D3D3
D3
Xi SiZhe
 
PhoneGap in 60 Minutes or Less
PhoneGap in 60 Minutes or LessPhoneGap in 60 Minutes or Less
PhoneGap in 60 Minutes or Less
Troy Miles
 
Introduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsIntroduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven Documents
Michał Oniszczuk
 
Introduction to D3.js
Introduction to D3.jsIntroduction to D3.js
Introduction to D3.js
Oleksii Prohonnyi
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
Brian Moschel
 
D3 js
D3 jsD3 js
D3 js
Ynon Perek
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
D3.js workshop
D3.js workshopD3.js workshop
D3.js workshop
Anton Katunin
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Bryan Basham
 
PhoneGap @ Javascript Directions
PhoneGap @ Javascript DirectionsPhoneGap @ Javascript Directions
PhoneGap @ Javascript Directions
Tiang Cheng
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to Titanium
Techday7
 
PhoneGap JavaScript API vs Native Components
PhoneGap JavaScript API vs Native ComponentsPhoneGap JavaScript API vs Native Components
PhoneGap JavaScript API vs Native Components
TechAhead
 
PhoneGap in 60 Minutes or Less
PhoneGap in 60 Minutes or LessPhoneGap in 60 Minutes or Less
PhoneGap in 60 Minutes or Less
Troy Miles
 
Introduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsIntroduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven Documents
Michał Oniszczuk
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Ad

Similar to Learn javascript easy steps (20)

Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
JavaScript
JavaScriptJavaScript
JavaScript
tutorialsruby
 
JavaScript
JavaScriptJavaScript
JavaScript
tutorialsruby
 
Learn Javascript Basics
Learn Javascript BasicsLearn Javascript Basics
Learn Javascript Basics
Khushiar
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
Shrijan Tiwari
 
INTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.pptINTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.ppt
testvarun21
 
Java script browser objects 1
Java script browser objects 1Java script browser objects 1
Java script browser objects 1
H K
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
Tommy Vercety
 
Java script
Java scriptJava script
Java script
Ramesh Kumar
 
Javascript
Javascript Javascript
Javascript
poojanov04
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Nuzhat Memon
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 
JavaScript
JavaScriptJavaScript
JavaScript
Bharti Gupta
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
Week8
Week8Week8
Week8
Hazen Mos
 
Cos 432 web_security
Cos 432 web_securityCos 432 web_security
Cos 432 web_security
Michael Freyberger
 
JavaScript
JavaScriptJavaScript
JavaScript
Vidyut Singhania
 
Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
Java script
Java scriptJava script
Java script
Rajkiran Mummadi
 
INFT132 093 07 Document Object Model
INFT132 093 07 Document Object ModelINFT132 093 07 Document Object Model
INFT132 093 07 Document Object Model
Michael Rees
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
Learn Javascript Basics
Learn Javascript BasicsLearn Javascript Basics
Learn Javascript Basics
Khushiar
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
Shrijan Tiwari
 
INTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.pptINTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.ppt
testvarun21
 
Java script browser objects 1
Java script browser objects 1Java script browser objects 1
Java script browser objects 1
H K
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
Tommy Vercety
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Nuzhat Memon
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
INFT132 093 07 Document Object Model
INFT132 093 07 Document Object ModelINFT132 093 07 Document Object Model
INFT132 093 07 Document Object Model
Michael Rees
 
Ad

Learn javascript easy steps

  • 1. JavaScript - a Brief Introduction IMI PRINCE www.newsvelley.blogspot.com
  • 2. What is JavaScript • Object based (not object oriented) programming language – very limited object creation – a set of pre-defined objects associated with • HTML document structure – many HTML tags constitute JS Objects • Browser functionality – provides a limited API to Browser functionality
  • 3. Where did it come from • Originally called LiveScript at Netscape – started out to be a server side scripting language for providing database connectivity and dynamic HTML generation on Netscape Web Servers – Netscape decided it would be a good thing for their browsers and servers to speak the same language so it got included in Navigator – Netscape in alliance w/Sun jointly announced the language and its new name Java Script – Because of rapid acceptance by the web community Microsoft forced to include in IE Browser
  • 4. Browser compatibility • For the most part Java Script runs the same way in all popular browsers • There are many areas where there are slight differences in how Java Script will run • there will be a separate set of slides addressing these differences.
  • 5. JavaScript…Java ? • There is no relationship other than the fact that Java and JavaScript resemble each other (and C++) syntactically • JavaScript is pretty much the de-facto standard for client-side scripting (Internet Explorer also provides VBScript & JScript) • In Netscape browsers there is an API that allows JavaScript and Java applets embedded in the same page to converse
  • 6. What can it be used for • Some pretty amazing things…. – Text animation – graphic animation – simple browser based application – HTML forms submission – client-side forms data validation (relieving the server of this task) – web site navigation
  • 7. What do I need to get started • A web browser – Netscape Navigator 4.x or later – MS Internet Explorer 3.x or later • A text Editor – Wordpad/Notepad – Vi, Emacs
  • 8. Process • Open your text editor • create a file containing html and Javascript • save as text file with file type .htm or .html • open your browser • click on file, open file – locate the file you just created • open file in browser
  • 9. Putting JavaScript into your HTML • in an external file – collect commonly used functions together into external function libraries on the server • added benefit of privacy from curious users • in-line with your HTML • as an expression for an HTML tag attribute • within some HTML tags as Event Handlers
  • 10. <SCRIPT>…</SCRIPT> • <SCRIPT language=…. src=……></SCRIPT> • The <SCRIPT> tag indicates to the browser the beginning of an embedded script; </SCRIPT> indicates the end of an embedded script. • the “language” attribute indicates the script processor to be used • the “src” attribute indicates the URL of a file on the server containing the script to be embedded
  • 11. Scripts • Since scripts are placed in line with with HTML older browsers will attempt to render them as text. • To preclude this hide them in side of an HTML comment . <!-- --> • for JavaScript comments use // or /* */
  • 12. <SCRIPT> • <SCRIPT LANGUAGE=“JavaScript”> • <!-- start hiding code from old browsers> • Script • Code • Goes • Here • // Stop Hiding code --> • </SCRIPT>
  • 13. Object Hierarchy window history document location link link anchor layer form applet image area text radio button fileUpload select textarea checkbox reset option password submit
  • 14. Objects • window - the current browser window • window.history - the Netscape history list • window.document - the html document currently in the browser client area • window.location - the browser location field • window.toolbar - the browser toolbar • window.document.link - an array containing all of the links in the document • window.document.anchor - an array of all the anchor points in the document
  • 15. Objects (more…) • Window.document.layer - a named document layer • window.document.applet - a named java applet area • window.document.image- a named image tag • window.document.area - a named area • window.document.form - a named form or the default form • ect, ect
  • 16. A few examples... • window.location = “http://www.yahoo.com” – will take you to the specified URL (like a goto) • window.history.back() – back() is a method on history – will be like clicking the back button in Nav 3 – in Nav 4 will take you back to prev window • window.history.goto(1) – takes you back to first URL in history array
  • 17. The Object Model • It is very important to understand the object model • each object has its own properties, some of which are read only some of which you can set directly by assignment (as location) • each object also has a set of behaviors called methods
  • 18. Object Model = Text Object HTML text tag B l u r () defaultValue form name Select() type focus() value Red - gettable and settable handleEvent
  • 19. Object Event Handlers • Most objects respond to asynchronous, user generated events through predefined event handlers that handle the event and transfer control to a user written event handling function • Each object has particular events that they will respond to • the way you specify an event handler is by adding an additional attribute to the HTML tag that specifies the particular handler • <input name=bt1 type=button value=ok onClick=“acb();”>
  • 20. Events • onAbort • onBlur • onChange • onClick • onError • onFocus • onLoad • onMouseOut • onMouseOver • onReset • onSelect • onSubmit • onUnload
  • 21. onAbort • Activated when a user aborts the loading of an image <img name=ball src=images/ball.gif onAbort=“alert(‘You missed a nice picture’)”>
  • 22. onBlur • Used with frame, select, text, textarea and window objects • invoked when an object loses the focus • use with select, text and textarea for data validation
  • 23. onChange • Used with select, text and textarea objects • use instead of onBlur to validate only if a value has changed <form> Color: <select onChange=“processSelection()”> <option value=“R”>Red <option value=“G”>Green <option value=“B”>Blue </select> </form>
  • 24. onClick • Used with button, checkbox,link, radio, reset, and submit objects. <input type=button name=btn1 value=“Click Me” onClick=“alert(‘button was clicked’;” >
  • 25. onError • Used with image and window objects to invoke a handler if an error occurs while an image or window is loading. • Setting window.onerror = null will prevent users from seeing JavaScript generated errors
  • 26. onFocus • Used with frame, select, text, textarea and window objects. • Just the opposite of onBlur; i.e. invoked when the object gets focus. <body bgcolor=“lightgrey” onBlur=“document.bgColor=‘black’ onFocus=“document.bgColor=‘white’” >
  • 27. onLoad • Used with window, frame and image objects (use with <body ….><frameset ….> and <img ...>) <img name=spinball src=images/spinball.gig onLoad=“startAnimation(this)”>
  • 28. onMouseOut and onMouseOver • Used with area and link objects • user moves mouse off of an area or link <map name=flower> <area name=top coords=“0,0,200,300 href=“javascript:displayMessage()” onMouseOver=“self.status=‘when you see this message click your left mouse button’ ; return true” onMouseOut=“self.status = ‘’ ; return true”>
  • 29. onReset • Used with form objects <form onReset=“alert(‘the form has been reset’)” >
  • 30. onSelect • Used with text and textarea objects • run some JavaScript whenever a user selects a piece of text in a text or textarea object <input type=text name=line onSelect=“showHelp()” >
  • 31. onSubmit • Use with form objects to run a handler whenever a form has been submitted. • Useful to validate all fields prior to actual submission
  • 32. onUnload • Just like onLoad but the handler is run when the window/frame is exited <body onUnload=“cleanup()” >