Scripts - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Scripts

Description:

DHTML. JavaScript can take a whole semester. Just the basics for now. Two Types of Scripts ... Load/run automatically when the page opens. Triggered scripts. Do ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 9
Provided by: frontier
Category:
Tags: dhtml | scripts

less

Transcript and Presenter's Notes

Title: Scripts


1
Chapter 18
  • Scripts
  • (JavaScript)

2
Quick Overview
  • Scripts are tiny programs inside a page
  • Allow interaction with page user
  • Sometimes called Dynamic HTML
  • DHTML
  • JavaScript can take a whole semester
  • Just the basics for now

3
Two Types of Scripts
  • Automatic scripts
  • Load/run automatically when the page opens
  • Triggered scripts
  • Do NOT run as soon as a page opens
  • Instead, triggered by some event
  • Press button
  • Click a link
  • Mouse over an area of the page
  • etc.

4
Automatic Scripts
  • Can be useful when writing advanced scripts
  • Printing current date/time on page
  • New pop-up message when page opens
  • Can be annoying, so be careful

5
Triggered Scripts
  • Also known as intrinsic events
  • Script runs when user does something
  • onclick
  • ondblclick
  • onmouseover
  • See p. 316 317 for entire list of 18
  • When user interacts with an element
  • ltbodygt lta href...gt ltpgt ltdivgt ltspangt ltimg src...gt
  • any element (almost ... see p.448)

6
Triggered Scripts
Easiest example ltspan onclickalert('I like
grapefruit')gt some text lt/spangt
7
Triggered Scripts Hints
  • If you need to use an apostrophe in your alert
  • backslash it
  • onclickalert('Who\'s there?')
  • Pay attention to single and double quotes
  • If you make a script in an empty element
  • ltdivgt lt/divgt
  • make sure your CSS forces a width and/or height

8
Buttons
  • You can make buttons to run a triggered script
  • ltbutton typebutton
  • namesomename
  • onclickalert('You pushed a button')
  • backgroundyellow colorredgt
  • Push this button
  • lt/buttongt
Write a Comment
User Comments (0)
About PowerShow.com