Содержание
- 2. Overview Some basic HTML And principles and issues W3C Standards that are relevant DOM, XML, XHTML,
- 3. Readings Many on-line tutorials www.w3schools.com/Xhtml Other on-line references (report!) Our textbook Chap. 12 on HTML Virtual
- 4. HTML Background Many “markup” languages in the past SGML: Standard Generalized Markup Language HTML (Hypertext Markup
- 5. Principles Distinguish structure from presentation Presentation based on structure Presentation may vary, perhaps based on display
- 7. Tags and Elements Example of an element: content Begin and end tags set off a section
- 8. Basic HTML Structure Comments: Example: … ….
- 9. Larger Example An Example An Example Hello World! I am 21. Green Yellow John Mike
- 10. Displays As…
- 11. Basic Tags Text display: , , Structure: , , , , Attributes: Align, text, bgcolor, etc.
- 12. Basic Tags (2) Links: … Images: an empty tag Tables Use an editor! Forms: later
- 13. More HTML Learn on your own You may never code in “raw” HTML You may need
- 14. Question: You’re writing software to process an HTML page A web-browser engine, for example What data
- 15. Discuss and give me details
- 16. Document Object Model (DOM) An model for describing HTML documents (and XML documents) A standard (ok,
- 17. DOM You 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
- 19. JavaScript An example of a “scripting” langauge that is embedded in HTML documents The browser’s display
- 20. History JavaScript created by Netscape JScript created by Microsoft IE and Netscape renderings are slightly different
- 21. General Format Name of web page ...script goes here ...page body here: text, forms, tables ...more
- 22. Characteristics Case sensitive Object oriented Produces an HTML document Dynamically typed Standard operator precedence Overloaded operators
- 23. Characteristics Division with / is not integer division Modulus (%) is not an integer operator 5
- 24. Characteristics " and ' can be used in pairs Scope rules for variables Strings are very
- 25. JavaScript Topics code placement document.writeln document tags window.alert user input/output parseInt and parseFloat arithmetic arithmetic comparisons
- 26. JavaScript Topics functions random numbers rolling dice form input form output submit buttons games arrays searching
- 27. JavaScript’s Uses Include: “Dynamic” web-pages What’s DHTML? (in a second) Image manipulation Swapping, rollovers, slide shows,
- 28. What’s DHTML? Purpose: make dynamic / interactive web-pages on the client side Use of a collection
- 29. Other References CS453 Virtual Lab exercises The Web Wizard’s Guide To JavaScript, Steven Estrella, Addison-Wesley JavaScript
- 30. Browser Compatability Use of: “language=“ for pre IE5 and NS6 Comment for very old browsers (e.g.
- 31. Organization of JavaScript Create functions (non-OO style) Define in header Or load a .js file in
- 32. JavaScript Programming by example
- 33. document.writeln Welcome to JavaScript document.writeln( " Welcome to ", "JavaScript Programming! " );
- 34. document.write Using document.write document.write ( " Welcome to "); document.writeln( "JavaScript Programming! " );
- 35. window.alert Using 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 entered by user secondNumber, // second string entered by
- 37. Functions var input1 = window.prompt( "Enter first number", "0" ); var input2 = window.prompt( "Enter second
- 38. Random Numbers var value; document.writeln( " Random Numbers " + " " ); for ( var
- 39. Roll the Die var frequency1 = 0, frequency2 = 0, frequency3 = 0, frequency4 = 0,
- 40. Rules of Craps First roll: 7 or 11 is a win 2, 3, or 12 is
- 41. Craps // variables used to test the state of the game var WON = 0, LOST
- 42. Craps // process one roll of the dice function play() { if ( firstRoll ) {
- 43. Craps default: // remember point gameStatus = CONTINUE_ROLLING; myPoint = sumOfDice; document.craps.point.value = myPoint; firstRoll =
- 44. Craps if ( gameStatus == CONTINUE_ROLLING ) window.alert ("Roll again"); else { if ( gameStatus ==
- 45. Craps // roll the dice function rollDice() { var die1, die2, workSum; die1 = Math.floor( 1
- 46. Poker Hand function rand1toN(N) { return Math.floor( 1+Math.random()*N ); } function dealcard(card) { var rank =
- 47. Poker Hand var card = new Array(2); var player = new Array(10); var dealer = new
- 48. Poker Hand document.writeln(" PLAYER "); document.writeln(" "); for (var i=0; i document.writeln(" " + player[i*2] +
- 49. Character Processing var s = "ZEBRA"; var s2 = "AbCdEfG"; document.writeln( " Character at index 0
- 50. Dates and Times var current = new Date(); document.writeln(current); document.writeln( " String representations and valueOf "
- 51. Dates and Times document.writeln( " Specifying arguments for a new Date " ); var anotherDate =
- 52. Radio buttons Assure that at least one radio button is clicked before taking action
- 53. Checkboxes Respond to selections made with checkboxes
- 54. Textboxes Detecting an empty textbox
- 55. Self-grading Tests Collecting and evaluating answers to questions
- 56. Character String Processing Validate an email address
- 57. Cookies Write a cookie on the client's device
- 58. Events JavaScript can execute a statement (typically, call a function) when an event occurs
- 59. Events onsubmit - call when submit button is clicked onclick - call when this button is
- 60. Mouse Events Illustrate onmouseover and onmouseout
- 61. Handling Time Create a simple JavaScript clock
- 62. Controlling Time Turn a clock on and off and format the time string
- 63. Handling Images Create a slide show
- 64. Generate Real-Time Data Simulate monitoring real-time information from a device
- 65. Continuous Update Gather data synchronously using the clock as the event generator
- 67. Скачать презентацию