Core: Data Conversion with - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Core: Data Conversion with

Description:

... href='next.html' onClick='doSomething( Next');' Nic Shulver, ... onClick() onMouseOut() onMouseOver() onBlur() onFocus() onChange() onReset() onSubmit() onLoad ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 9
Provided by: gawainSoc
Category:

less

Transcript and Presenter's Notes

Title: Core: Data Conversion with


1
Core Data Conversion with
  • x 10 2 // 12
  • x my word // my word
  • x 10 2 // 12
  • x 4 true // 5
  • x 4 true // 4true
  • x window 1 // object Window1
  • x window true // object Windowtrue

2
Core More Data Conversion
  • x Math.sin(1.234) // uses value 1.234
  • if(nSum gt 22) ... // uses value 22
  • x x - 1 // uses value 1
  • x x - // uses value 0
  • x x // converts x to a string
  • x x y.toString() // x holds string value
  • x (123).toString() // equivalent to x 123

3
Core Strings to numbers
  • x parseInt(22 Acacia Avenue) // 22
  • x parseFloat(5.87 pounds) // 5.87
  • x parseInt(0xFF) // 255
  • x parseInt(FF, 16) // 255
  • x parseInt(two) // NaN or 0 (N2, IE3)
  • x eval(3.2(1y)) // 3.2(1y)
  • x eval(ygt3) // true or false

4
Client-Side Stuff
  • ltscript languageSomeValidLanguagegt
  • lt!-- code hiding from old browsers
  • program stuff
  • program stuff
  • program stuff
  • // end of code hiding --gt
  • lt/scriptgt

5
Client-Side Stuff
  • SomeValidLanguage is VBScript or JavaScript
    or JavaScript1.1 or JavaScript1.2...
  • A ltscriptgt block may appear in the ltheadgt or
    ltbodygt block of a HTML file.
  • Multiple, non-overlapping ltscriptgt blocks may
    appear.
  • ltscriptgt blocks will be executed in the order
    they appear.

6
Event Handlers
  • Some HTML tags support event handlers.
  • This means that we can run simple code or invoke
    a JavaScript function when certain events occur.
  • Examples
  • ltbody onLoadbLoadedtrue nStartup22gt
  • lta hrefnext.html onClickdoSomething(Next)
    gt

7
Events you may need
  • Note Not all HTML objects support all events.
  • Below are the main event handlers in no special
    order.
  • onClick() onMouseOut() onMouseOver()
  • onBlur() onFocus() onChange()
  • onReset() onSubmit() onLoad()
  • onUnload() onAbort() onError()

8
Timer Events
  • JavaScript has a built in timer available
  • setTimeout(myTickFunction(), 1000)
  • The above sets the timer to wait for 1000
    milliseconds (one second), then call
    myTickFunction().
  • The setTimeout() function only causes one timer
    tick event, it is not a clock.
  • The clearTimeout() can cancel a pending event.
Write a Comment
User Comments (0)
About PowerShow.com