Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему HTML documents and JavaScript

Содержание

OverviewSome basic HTMLAnd principles and issuesW3C Standards that are relevantDOM, XML, XHTML, ECMAScriptJavaScript introductionYour tasks:HTML, JavaScript exercises in VirtualLabsHomework 2 on JavaScript
HTML Documents and JavaScriptTom HortonAlfred C. WeaverCS453 Electronic Commerce OverviewSome basic HTMLAnd principles and issuesW3C Standards that are relevantDOM, XML, XHTML, ReadingsMany on-line tutorialswww.w3schools.com/XhtmlOther on-line references (report!)Our textbookChap. 12 on HTMLVirtual Lab exercisesOn HTML, JavaScript HTML BackgroundMany “markup” languages in the pastSGML: Standard Generalized Markup LanguageHTML (Hypertext PrinciplesDistinguish structure from presentationPresentation based on structurePresentation may vary, perhaps based on Tags and ElementsExample of an element:  contentBegin and end tags set Basic HTML StructureComments: Example: Larger ExampleAn ExampleAn Example  Hello World!I am 21. Displays As… Basic TagsText display:, , Structure:, , , , Attributes:Align, text, bgcolor, etc. Basic Tags (2)Links: 	…Images: an empty tagTablesUse an editor!Forms: later More HTMLLearn on your ownYou may never code in “raw” HTMLYou may Question:You’re writing software to process an HTML pageA web-browser engine, for exampleWhat Discuss and give me details Document Object Model (DOM)An model for describing HTML documents (and XML documents)A DOMYou get anything you want from…   More info: http://en.wikipedia.org/wiki/Document_Object_Model W3C StandardsXML, XHTMLCSS, XSLXSLTDOMECMAScriptetc JavaScriptAn example of a “scripting” langauge that is embedded in HTML documentsThe HistoryJavaScript created by NetscapeJScript created by MicrosoftIE and Netscape renderings are slightly General Format Name of web page ...script goes here CharacteristicsCase sensitiveObject orientedProduces an HTML documentDynamically typedStandard operator precedenceOverloaded operatorsReserved words Characteristics	Division with / is not integer divisionModulus (%) is not an integer Characteristics	JavaScript Topicscode placementdocument.writelndocument tagswindow.alertuser input/outputparseInt and parseFloatarithmeticarithmetic comparisonsfor loops while loopsdo-while loopsif-elsevariable JavaScript Topicsfunctionsrandom numbersrolling diceform inputform outputsubmit buttonsgamesarrayssearchingstringssubstringsstring conversionsmarkup methods JavaScript’s Uses Include:“Dynamic” web-pagesWhat’s DHTML? (in a second)Image manipulationSwapping, rollovers, slide shows, What’s DHTML?Purpose: make dynamic / interactive web-pages on the client sideUse of Other ReferencesCS453 Virtual Lab exercisesThe Web Wizard’s Guide To JavaScript, Steven Estrella, Browser CompatabilityUse of:   “language=“ for pre IE5 and NS6Comment for Organization of JavaScriptCreate functions (non-OO style)Define in headerOr load a .js file JavaScriptProgramming by example document.writeln Welcome to JavaScript  	document.writeln( document.write  Using document.write  	document.write (  window.alert Using window.alert 	window.alert( User input/output	var firstNumber,  // first string entered by user	secondNumber,  // Functions	var input1 = window.prompt( Random Numbers	var value;	document.writeln( Roll the Die	var frequency1 = 0, frequency2 = 0,	frequency3 = 0, frequency4 Rules of CrapsFirst roll:7 or 11 is a win2, 3, or 12 Craps// variables used to test the state of the game var WON Craps// process one roll of the dicefunction play() {  if ( Crapsdefault:      // remember point Crapsif ( gameStatus == CONTINUE_ROLLING ) window.alert ( Craps// roll the dicefunction rollDice() {  var die1, die2, workSum; Poker Handfunction rand1toN(N) {  return Math.floor( 1+Math.random()*N );  }function dealcard(card) Poker Handvar card = new Array(2);var player = new Array(10);var dealer = Poker Handdocument.writeln( Character Processingvar s = Dates and Timesvar current = new Date();document.writeln(current);document.writeln( Dates and Timesdocument.writeln( Radio buttonsAssure that at least one radio button is clicked before taking action CheckboxesRespond to selections made with checkboxes TextboxesDetecting an empty textbox Self-grading TestsCollecting and evaluating answers to questions Character String ProcessingValidate an email address CookiesWrite a cookie on the client's device EventsJavaScript can execute a statement (typically, call a function) when an event occurs Eventsonsubmit - call when submit button is clickedonclick - call when this Mouse EventsIllustrate onmouseover and onmouseout Handling TimeCreate a simple JavaScript clock Controlling TimeTurn a clock on and off and format the time string Handling ImagesCreate a slide show Generate Real-Time DataSimulate monitoring real-time information from a device Continuous UpdateGather data synchronously using the clock as the event generator End of Examples
Слайды презентации

Слайд 2 Overview
Some basic HTML
And principles and issues
W3C Standards that

OverviewSome basic HTMLAnd principles and issuesW3C Standards that are relevantDOM, XML,

are relevant
DOM, XML, XHTML, ECMAScript
JavaScript introduction
Your tasks:
HTML, JavaScript exercises

in VirtualLabs
Homework 2 on JavaScript

Слайд 3 Readings
Many on-line tutorials
www.w3schools.com/Xhtml
Other on-line references (report!)
Our textbook
Chap. 12

ReadingsMany on-line tutorialswww.w3schools.com/XhtmlOther on-line references (report!)Our textbookChap. 12 on HTMLVirtual Lab exercisesOn HTML, JavaScript

on HTML
Virtual Lab exercises
On HTML, JavaScript


Слайд 4 HTML Background
Many “markup” languages in the past
SGML: Standard

HTML BackgroundMany “markup” languages in the pastSGML: Standard Generalized Markup LanguageHTML

Generalized Markup Language
HTML (Hypertext Markup Language) based on SGML
XML

(eXtensible Markup Language) “replaces” SGML
XHTML is replacing HTML

Слайд 5 Principles
Distinguish structure from presentation
Presentation based on structure
Presentation may

PrinciplesDistinguish structure from presentationPresentation based on structurePresentation may vary, perhaps based

vary, perhaps based on display characteristics, user-preference, etc.
People like

to ignore this idea
E.g. use vs.
tag?
XML and CSS or XSL

Слайд 7 Tags and Elements
Example of an element: content
Begin

Tags and ElementsExample of an element: contentBegin and end tags set

and end tags set off a section of a

document
Has a semantic property by tag-name
Modified by attributes
“content” can contain other elements
Elements nest, don’t “overlap”
Empty-elements: no end tag


Note space before />

Слайд 8 Basic HTML Structure
Comments:
Example:

Basic HTML StructureComments: Example:       …


….




<--- title, meta-tags, etc. (not displayed)

<--- main content (displayed)


Слайд 9 Larger Example


An Example


An Example

Larger ExampleAn ExampleAn Example Hello World!I am 21.  Green Yellow

MS" size="4">
Hello World!


I am 21.

see next column -->




  1. Green

  2. Yellow


    • John

    • Mike







Слайд 10 Displays As…

Displays As…

Слайд 11 Basic Tags
Text display:
, ,
Structure:
, ,

, ,

Basic TagsText display:, , Structure:, , , , Attributes:Align, text, bgcolor, etc.


Attributes:
Align, text, bgcolor, etc.


Слайд 12 Basic Tags (2)
Links: …
Images:
an empty tag
Tables
Use

Basic Tags (2)Links: 	…Images: an empty tagTablesUse an editor!Forms: later

an editor!
Forms: later


Слайд 13 More HTML
Learn on your own
You may never code

More HTMLLearn on your ownYou may never code in “raw” HTMLYou

in “raw” HTML
You may need to tweak HTML files

created by a tool
You will need to understand HTML to code in JavaScript etc.
You will need to understand HTML to know limitations on how docs on the web can be structured

Слайд 14 Question:
You’re writing software to process an HTML page
A

Question:You’re writing software to process an HTML pageA web-browser engine, for

web-browser engine, for example
What data structure would best represent

an HTML document?
Why?

Слайд 15 Discuss and give me details

Discuss and give me details

Слайд 16 Document Object Model (DOM)
An model for describing HTML

Document Object Model (DOM)An model for describing HTML documents (and XML

documents (and XML documents)
A standard (ok, standards)
Independent of browser,

language
(ok, mostly)
A common set of properties/methods to access everything in a web document
APIs in JavaScript, for Java, etc.

Слайд 17 DOM
You get anything you want from…

More info: http://en.wikipedia.org/wiki/Document_Object_Model

DOMYou get anything you want from…  More info: http://en.wikipedia.org/wiki/Document_Object_Model

Слайд 18 W3C Standards
XML, XHTML
CSS, XSL
XSLT
DOM
ECMAScript
etc

W3C StandardsXML, XHTMLCSS, XSLXSLTDOMECMAScriptetc

Слайд 19 JavaScript
An example of a “scripting” langauge that is

JavaScriptAn example of a “scripting” langauge that is embedded in HTML

embedded in HTML documents
The browser’s display engine must distinguish

from HTML and Script statements
Others like this:
PHP (later in the course)

Слайд 20 History
JavaScript created by Netscape
JScript created by Microsoft
IE and

HistoryJavaScript created by NetscapeJScript created by MicrosoftIE and Netscape renderings are

Netscape renderings are slightly different
Standardized by European Computer Manufacturers

Association (ECMA)
http://www.ecma-international. org/publications /standards/Ecma-262.htm

Слайд 21 General Format



Name of web page

General Format Name of web page ...script goes here



...script goes here

JavaScript if needed
...onload, onclick, etc. commands here



Слайд 22 Characteristics
Case sensitive
Object oriented
Produces an HTML document
Dynamically typed
Standard operator

CharacteristicsCase sensitiveObject orientedProduces an HTML documentDynamically typedStandard operator precedenceOverloaded operatorsReserved words

precedence
Overloaded operators
Reserved words


Слайд 23 Characteristics
Division with / is not integer division
Modulus (%)

Characteristics	Division with / is not integer divisionModulus (%) is not an

is not an integer operator
5 / 2 yields 2.5
5.1

/ 2.1 yields 2.4285714285714284
5 % 2 yields 1
5.1 % 2.1 yields 0.8999999999999995



Слайд 24 Characteristics
" and ' can be used in pairs
Scope

Characteristics

rules for variables
Strings are very common data types
Rich set

of methods available
Arrays have dynamic length
Array elements have dynamic type
Arrays are passed by reference
Array elements are passed by value


Слайд 25 JavaScript Topics
code placement
document.writeln
document tags
window.alert
user input/output
parseInt and parseFloat
arithmetic
arithmetic comparisons
for

JavaScript Topicscode placementdocument.writelndocument tagswindow.alertuser input/outputparseInt and parseFloatarithmeticarithmetic comparisonsfor loops while loopsdo-while

loops

while loops
do-while loops
if-else
variable values in tags
math library
switch
break
labeled break
continue
Booleans




Слайд 26 JavaScript Topics
functions
random numbers
rolling dice
form input
form output
submit buttons
games
arrays
searching
strings
substrings
string conversions
markup

JavaScript Topicsfunctionsrandom numbersrolling diceform inputform outputsubmit buttonsgamesarrayssearchingstringssubstringsstring conversionsmarkup methods

methods


Слайд 27 JavaScript’s Uses Include:
“Dynamic” web-pages
What’s DHTML? (in a second)
Image

JavaScript’s Uses Include:“Dynamic” web-pagesWhat’s DHTML? (in a second)Image manipulationSwapping, rollovers, slide

manipulation
Swapping, rollovers, slide shows, etc.
Date, time stuff (e.g. clocks,

calendars)
HTML forms processing
Verifying input; writing output to fields
Cookies

Слайд 28 What’s DHTML?
Purpose: make dynamic / interactive web-pages on

What’s DHTML?Purpose: make dynamic / interactive web-pages on the client sideUse

the client side
Use of a collection of technologies together

to do this, including
Markup language (HTML, XML, etc.)
Scripting language (JavaScript, etc.)
Presentation language (CSS etc.)


Слайд 29 Other References
CS453 Virtual Lab exercises
The Web Wizard’s Guide

Other ReferencesCS453 Virtual Lab exercisesThe Web Wizard’s Guide To JavaScript, Steven

To JavaScript, Steven Estrella, Addison-Wesley
JavaScript for the World Wide

Web, Gesing and Schneider, Peachpit Press
http://www.w3schools.com/js/
www.javascript.com
E-books in UVa’s Safari On-line Books: http://proquest.safaribooksonline.com/search

Слайд 30 Browser Compatability
Use of:

Browser CompatabilityUse of:  “language=“ for pre IE5 and NS6Comment for

hiding -->
“language=“ for pre IE5 and NS6
Comment for very

old browsers (e.g. IE2)
BTW, comments in HTML vs. in JavaScript

Слайд 31 Organization of JavaScript
Create functions (non-OO style)
Define in header
Or

Organization of JavaScriptCreate functions (non-OO style)Define in headerOr load a .js

load a .js file in header:

src="/mylib.js">
Functions called in
Often in response to events, e.g.
Global variables

Слайд 32 JavaScript
Programming by example

JavaScriptProgramming by example

Слайд 33 document.writeln


document.writeln Welcome to JavaScript 	document.writeln(

to JavaScript -->

Welcome to JavaScript

document.writeln(

"

Welcome to ",
"JavaScript Programming!

" );







Слайд 34 document.write



document.write Using document.write  	document.write (

Using document.write

document.write ( "Welcome

to ");
document.writeln( "JavaScript Programming!" );







Слайд 35 window.alert



Using

window.alert Using window.alert 	window.alert(

window.alert

window.alert( "Welcome to\nJavaScript\nProgramming!" );



Click Refresh (or Reload)

to run this script again.






Слайд 36 User input/output

var firstNumber, // first string

User input/output	var firstNumber, // first string entered by user	secondNumber, // second

entered by user
secondNumber, // second string entered by

user
number1, // first number to add
number2, // second number to add
sum; // sum of number1 and number2
// read in first number from user as a string
firstNumber = window.prompt("Enter first integer", "0" );
// read in second number from user as a string
secondNumber = window.prompt( "Enter second integer", "0" );
// convert numbers from strings to integers
firstNumber = parseInt(firstNumber);
number2 = parseInt( secondNumber );
// add the numbers
sum = firstNumber + number2;
// display the results
document.writeln( "

The sum is " + sum + "

" );



Слайд 38 Random Numbers

var value;
document.writeln( "Random Numbers" +

Random Numbers	var value;	document.writeln(

"" );
for (

var i = 1; i <= 20; i++ ) {
value = Math.floor( 1 + Math.random() * 6 );
document.writeln( "" + value + "" );
if ( i % 5 == 0 && i != 20 )
document.writeln( "" );
}
document.writeln( "" );



Слайд 39 Roll the Die

var frequency1 = 0, frequency2

Roll the Die	var frequency1 = 0, frequency2 = 0,	frequency3 = 0,

= 0,
frequency3 = 0, frequency4 = 0,
frequency5 = 0,

frequency6 = 0, face;
// summarize results
for ( var roll = 1; roll <= 6000; ++roll ) {
face = Math.floor( 1 + Math.random() * 6 );
switch ( face ) {
case 1: ++frequency1; break;
case 2: ++frequency2; break;
case 3: ++frequency3; break;
case 4: ++frequency4; break;
case 5: ++frequency5; break;
case 6: ++frequency6; break;
}
}
document.writeln( "" ); .....



Слайд 40 Rules of Craps
First roll:
7 or 11 is a

Rules of CrapsFirst roll:7 or 11 is a win2, 3, or

win
2, 3, or 12 is a lose
otherwise, roll becomes

your point
Subsequent rolls:
rolling your point is a win
7 or 11 is a lose
otherwise continue to roll



Слайд 41 Craps

// variables used to test the state

Craps// variables used to test the state of the game var

of the game
var WON = 0, LOST =

1, CONTINUE_ROLLING = 2;
// other variables used in program
var firstRoll = true, // true if first roll
sumOfDice = 0, // sum of the dice
myPoint = 0, // point if no win/loss on first roll
gameStatus = CONTINUE_ROLLING; // game not over yet

Слайд 42 Craps
// process one roll of the dice
function play()

Craps// process one roll of the dicefunction play() { if (

{
if ( firstRoll ) {

// first roll of the dice
sumOfDice = rollDice();
switch ( sumOfDice ) {
case 7: case 11:
// win on first roll
gameStatus = WON;
document.craps.point.value = ""; // clear point field
break;
case 2: case 3: case 12:
// lose on first roll
gameStatus = LOST;
document.craps.point.value = ""; // clear point field
break;

Слайд 43 Craps
default:
// remember

Crapsdefault:   // remember point   gameStatus = CONTINUE_ROLLING;

point
gameStatus = CONTINUE_ROLLING;

myPoint = sumOfDice;
document.craps.point.value = myPoint;
firstRoll = false;
}
}
else {
sumOfDice = rollDice();
if ( sumOfDice == myPoint ) gameStatus = WON;
else if ( sumOfDice == 7 ) gameStatus = LOST;
}


Слайд 44 Craps
if ( gameStatus == CONTINUE_ROLLING ) window.alert ("Roll

Crapsif ( gameStatus == CONTINUE_ROLLING ) window.alert (

again");
else {
if ( gameStatus

== WON ) {
window.alert ("Player wins. " + "Click Roll Dice to play again.");
document.craps.point.value = " ";
}
else {
window.alert ("Player loses. " + "Click Roll Dice to play again.");
document.craps.point.value = " ";
}
firstRoll = true;
}
}




Слайд 45 Craps
// roll the dice
function rollDice() {
var

Craps// roll the dicefunction rollDice() { var die1, die2, workSum; die1

die1, die2, workSum;
die1 = Math.floor( 1 +

Math.random() * 6 );
die2 = Math.floor( 1 + Math.random() * 6 );
workSum = die1 + die2;
document.craps.firstDie.value = die1;
document.craps.secondDie.value = die2;
document.craps.sum.value = workSum;
return workSum;
}




Слайд 46 Poker Hand

function rand1toN(N) {
return Math.floor(

Poker Handfunction rand1toN(N) { return Math.floor( 1+Math.random()*N ); }function dealcard(card) {

1+Math.random()*N );
}
function dealcard(card) {
var rank

= new Array(0,"A","2","3","4","5","6","7",
"8","9","T","J","Q","K");
var suit = new Array(0, "Spades", "Hearts", "Diamonds", "Clubs");
card[0] = rank[rand1toN(13)];
card[1] = suit[rand1toN(4)];
}

Слайд 47 Poker Hand
var card = new Array(2);
var player =

Poker Handvar card = new Array(2);var player = new Array(10);var dealer

new Array(10);
var dealer = new Array(10);
for (var i=0; i

i++) {
dealcard(card);
player[i*2] = card[0];
player[i*2+1] = card[1];
dealcard(card);
dealer[i*2] = card[0];
dealer[i*2+1] = card[1];
}


Слайд 48 Poker Hand
document.writeln(" PLAYER ");
document.writeln("");
for (var i=0;

Poker Handdocument.writeln(

i

+ "
");
}
document.writeln("

" + player[i*2+1] + "

");




Слайд 49 Character Processing

var s = "ZEBRA";
var s2 =

Character Processingvar s =

"AbCdEfG";
document.writeln( " Character at index 0 in '"+

s + '" is " + s.charAt( 0 ) );
document.writeln( "
Character code at index 0 in '" +
s + "' is " + s.charCodeAt( 0 ) + "

" );
document.writeln( "

'" + String.fromCharCode( 87, 79, 82, 68 ) +
"' contains character codes 87, 79, 82 and 68

" );
document.writeln( "

'" + s2 + "' in lowercase is '" +
s2.toLowerCase() + "'" );
document.writeln( "
'" + s2 + "' in uppercase is '" +
s2.toUpperCase() + "'

" );



Слайд 50 Dates and Times

var current =

Dates and Timesvar current = new Date();document.writeln(current);document.writeln(

new Date();
document.writeln(current);
document.writeln( "String representations and valueOf" );
document.writeln( "toString: "

+ current.toString() +
"
toLocaleString: " + current.toLocaleString() +
"
toUTCString: " + current.toUTCString() +
"
valueOf: " + current.valueOf() );
document.writeln( "

Get methods for local time zone

" );
document.writeln( "getDate: " + current.getDate() +
"
getDay: " + current.getDay() + "
getMonth: " +
current.getMonth() + "
getFullYear: " + current.getFullYear() +
"
getTime: " + current.getTime() + "
getHours: " +
current.getHours() + "
getMinutes: " + current.getMinutes() +
"
getSeconds: " + current.getSeconds() + "
getMilliseconds: " +
current.getMilliseconds() + "
getTimezoneOffset: " +
current.getTimezoneOffset() );

Слайд 51 Dates and Times
document.writeln( "Specifying arguments for a new

Dates and Timesdocument.writeln(

Date" );


var anotherDate = new Date( 1999, 2, 18, 1, 5, 3, 9 );
document.writeln( "Date: " + anotherDate );
document.writeln( "

Set methods for local time zone

" );
anotherDate.setDate( 31 );
anotherDate.setMonth( 11 );
anotherDate.setFullYear( 1999 );
anotherDate.setHours( 23 );
anotherDate.setMinutes( 59 );
anotherDate.setSeconds( 59 );
document.writeln( "Modified date: " + anotherDate );




Слайд 52 Radio buttons
Assure that at least one radio button

Radio buttonsAssure that at least one radio button is clicked before taking action

is clicked before taking action



Слайд 53 Checkboxes
Respond to selections made with checkboxes

CheckboxesRespond to selections made with checkboxes

Слайд 54 Textboxes
Detecting an empty textbox

TextboxesDetecting an empty textbox

Слайд 55 Self-grading Tests
Collecting and evaluating answers to questions

Self-grading TestsCollecting and evaluating answers to questions

Слайд 56 Character String Processing
Validate an email address

Character String ProcessingValidate an email address

Слайд 57 Cookies
Write a cookie on the client's device


CookiesWrite a cookie on the client's device

Слайд 58 Events
JavaScript can execute a statement (typically, call a

EventsJavaScript can execute a statement (typically, call a function) when an event occurs

function) when an event occurs


TYPE="submit" … ONSUBMIT="f();">



Слайд 59 Events
onsubmit - call when submit button is clicked
onclick

Eventsonsubmit - call when submit button is clickedonclick - call when

- call when this button is clicked
onreset - call

when the reset button is clicked
onload - call after page loads
onmouseover - call when mouse pointer enters image area
onmouseout - call when mouse pointer leaves image area
onfocus - call when control receives focus
onblur - call when a control loses focus
onchange - call when a control loses focus and the value of its contents has changed
many more

Слайд 60 Mouse Events
Illustrate onmouseover and onmouseout

Mouse EventsIllustrate onmouseover and onmouseout

Слайд 61 Handling Time
Create a simple JavaScript clock

Handling TimeCreate a simple JavaScript clock

Слайд 62 Controlling Time
Turn a clock on and off and

Controlling TimeTurn a clock on and off and format the time string

format the time string


Слайд 63 Handling Images
Create a slide show

Handling ImagesCreate a slide show

Слайд 64 Generate Real-Time Data
Simulate monitoring real-time information from a

Generate Real-Time DataSimulate monitoring real-time information from a device

device


Слайд 65 Continuous Update
Gather data synchronously using the clock as

Continuous UpdateGather data synchronously using the clock as the event generator

the event generator


  • Имя файла: html-documents-and-javascript.pptx
  • Количество просмотров: 133
  • Количество скачиваний: 1