Mark Dixon Page 1 03 – Dynamic HTML (client-side scripting)

Slides:



Advertisements
Similar presentations
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Advertisements

The Web Warrior Guide to Web Design Technologies
Mark Dixon, SoCCE SOFT 136Page 1 02 – Software Development Life-Cycle.
Mark Dixon Page 1 05 – Conditional Execution. Mark Dixon Page 2 Admin: Test (next week) In class test –teaching week 6 50 minutes short answer (5 - 6.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: HTML and Client-side code.
Mark Dixon Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon, SoCCE SOFT 131Page 1 16 – Web applications: HTML and Client-side code.
Tutorial 10 Programming with JavaScript
Information Technology Center Hany Abdelwahab Computer Specialist.
Mark Dixon, SoCCE SOFT 131Page 1 04 – Conditional Execution.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Mark Dixon, SoCCE SOFT 131Page 1 08 – Web applications: HTML and ActiveX controls.
Mark Dixon Page 1 Tech – HTML. Mark Dixon Page 2 Admin Attendance Register: –log in to your profile.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
M Dixon 1 Web-Application Development Workshop. M Dixon 2 Session Aims & Objectives Aims –to introduce the main concepts involved in creating web-applications.
02 – Client-side code: JavaScript
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
M Dixon 1 Soft – Module Introduction and HTML.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
M Dixon 1 04 – Data Types & Debugging. Questions: Expressions a)What is the result of: 7 + Int(8.245) b)Write an expression to: put a random number into.
Mark Dixon 1 05 – Conditional Execution. Mark Dixon 2 Admin: Test (next week) In class test –teaching week 6 50 minutes short answer (5 - 6 words) currently.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 06 – Conditional Execution. Mark Dixon Page 2 Admin: Test (next week) In class test –teaching week 6 50 minutes short answer (5 - 6.
Mark Dixon, SoCCE SOFT 131Page 1 05 – Variables. Mark Dixon, SoCCE SOFT 131Page 2 Admin: Test (next week) In class test –teaching week 6 –university week.
Mark Dixon Page 1 Soft – Module Introduction and HTML.
Mark Dixon Page 1 Web-Application Development Workshop.
M Dixon 1 03 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 04 – Information Processing: Expressions, Operators & Functions.
M Dixon 1 Web-Application Development Workshop. M Dixon 2 Session Aims & Objectives Aims –to introduce the main concepts involved in creating web-applications.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Expressions, Operators & Functions.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 03 – Dynamic HTML (client-side scripting)
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
M Dixon 1 Tech HTML. M Dixon 2 Admin Attendance Register: –log in to your profile.
Mark Dixon Page 1 Soft – HTML. Mark Dixon Page 2 Admin Attendance Register: –log in to your profile.
Mark Dixon Page 1 Tech – HTML. Mark Dixon Page 2 Admin Attendance Register: –log in to your profile.
Mark Dixon Page 1 04 – Information Processing: Expressions, Operators & Functions.
Mark Dixon Page 1 04 – Information Processing: Expressions, Operators & Functions.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
Mark Dixon Page 1 08 – Variables. Mark Dixon Page 2 Questions: Conditional Execution What is the result of (txtFah.value is 50): (txtFah.value >= 40)
Mark Dixon Page 1 08 – Variables. Mark Dixon Page 2 Questions: Conditional Execution What is the result of (txtFah.value is 50): (txtFah.value >= 40)
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon 1 06 – Conditional Execution. Mark Dixon 2 Admin: Test (next week) In class test –teaching week 7 50 minutes short answer (5 - 6 words max)
M Dixon 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 04 – Conditional Execution. Mark Dixon Page 2 Questions: Expressions a)What is the result of: 10 * Int( ) b)How many functions.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
1 JavaScript and Dynamic Web Pages Lecture 7. 2 Static vs. Dynamic Pages  A Web page uses HTML tags to identify page content and formatting information.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Mark Dixon, SoCCE SOFT 131Page 1 03 – Conditional Execution.
XP Creating Web Pages with Microsoft Office
04 – Information Processing: Expressions, Operators & Functions
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
WEB PROGRAMMING JavaScript.
Tutorial 10: Programming with javascript
Introduction to Programming and JavaScript
Programming with Microsoft Visual Basic 2008 Fourth Edition
Presentation transcript:

Mark Dixon Page 1 03 – Dynamic HTML (client-side scripting)

Mark Dixon Page 2 Questions: HTML Consider the following HTML: Next Page a)Give an example of a tag b)Give an example of an element c)Give an example of an attribute Next Page href=“next.htm”

Mark Dixon Page 3 Questions: HTML a)Is the following a tag? Hello b)Is the following an element? c)Is the following an attribute? d)How many tags are there in: Title e)How many attributes are there in: No (element) No (start tag) 4 2

Mark Dixon Page 4 Admin: On-line Quiz Useful, but limited –multiple choice, same concepts –actual tests are free text

Mark Dixon Page 5 Session Aims & Objectives Aims –introduce you to the fundamental aspects of dynamic (interactive) web pages via client-side scripting Objectives, after this week’s sessions, you should be able to: –Add objects to a web-page –Create Event Handler Procedures to do things in response to an event of a object –Put Assignment instructions in the event handler, that change the value of properties at run-time –Enable and use the Interactive Debugger, and the immediate window

Mark Dixon Page 6 Dynamic processing (what) HTML is static –identical on each load –very limiting Dynamic processing –client-side: browser (this week) quicker (no request-response cycle) insecure (view source) limited (can't access server-side databases) –server-side: server application (next term) slower more powerful

Mark Dixon Page 7 Example: Colour Change Trigger (when)Actions (what) Click event of Red button Change background to Red MouseOver event of Red button Make button text capitals (RED) MouseOut event of Red button Make button text normal (Red) Click event of Blue button Change background to Blue MouseOver event of Blue button Make button text capitals (BLUE) MouseOut event of Blue button Make button text normal (Blue) Events: –Click: user releases left mouse button on object –MouseOver: mouse moves over object –MouseOut: mouse mouse moves off object

Mark Dixon Page 8 Active Content Allow active content:

Mark Dixon Page 9 Tags Colour Change Use tags to create buttons

Mark Dixon Page 10 Tag Colour Change Sub btnRed_OnClick() document.bgColor = "red" End Sub Sub btnRed_OnMouseOver() btnRed.value = "RED" End Sub Sub btnRed_OnMouseOut() btnRed.value = "Red" End Sub Visual BASIC Script Use tags to enclose script code

Mark Dixon Page 11 Event Handler Procedures Colour Change Sub btnRed_OnClick() document.bgColor = "red" End Sub Sub btnRed_OnMouseOver() btnRed.value = "RED" End Sub Sub btnRed_OnMouseOut() btnRed.value = "Red" End Sub Event Handler Procedure

Mark Dixon Page 12 Objects & Events Colour Change Sub btnRed_OnClick () document.bgColor = "red" End Sub Sub btnRed_OnMouseOver () btnRed.value = "RED" End Sub Sub btnRed_OnMouseOut () btnRed.value = "Red" End Sub Object Event

Mark Dixon Page 13 Instructions Colour Change Sub btnRed_OnClick() document.bgColor = "red" End Sub Sub btnRed_OnMouseOver() btnRed.value = "RED" End Sub Sub btnRed_OnMouseOut() btnRed.value = "Red" End Sub Assignment: Object.Property = Literal btnRed.Value = "Red"

Mark Dixon Page 14 Sequence Inside event procedures –lines executed in sequence

Mark Dixon Page 15 Assignment Statements Order is important: btnRed.Value = "Red" The above means: put "Red" into the Value of btnRed destination (must be object property) data flow source (object property or literal)

Mark Dixon Page 16 Errors: Assignment btnRed.Value = "Red" "Red" = btnRed.Value btnRed.Value = document.bgColor 67 = document.bgColor put "Red" into the Value of btnRed put the Value of btnRed into "Red" put the bgColor of the document into the Value of btnRed put the bgColor of the document into 67  

Mark Dixon Page 17 Errors: Sub Every Sub must have End Sub Colour Change Sub btnRed_OnClick() document.bgColor = "red" End Sub Sub btnRed_OnMouseOver() btnRed.value = "RED" Sub btnRed_OnMouseOut() btnRed.value = "Red" End Sub missing End Sub

Mark Dixon Page 18 Example: Puppy Freya's web page Welcome, Freya's web page. Freya likes her toy. Sub btnPuppy_OnClick() document.title = "Freya (large image)" picFace.src = "FaceLarge.jpg" End Sub

Mark Dixon Page 19 Errors: Duplicate Sub Can't have 2 Subs with same name Don't need to: put both lines in same Sub Freya's web page Welcome, Freya's web page. Freya likes her toy. Sub btnPuppy_OnClick() document.title = "Freya (large image)" End Sub Sub btnPuppy_OnClick() picFace.src = "FaceLarge.jpg" End Sub 

Mark Dixon Page 20 Example: Puppy (code) Freya's web page Welcome, Freya's web page. Freya likes her toy. Sub btnPuppy_OnClick() document.title = "Freya (large image)" picFace.src = "FaceLarge.jpg" End Sub Script ignored, until button pressed picture and button, given identifiers (names)

Mark Dixon Page 21 Question: Parts of Code In the following code, name: a)a property b)a keyword c)an object d)an event e)an event handler Sub btnPuppy_OnClick() document.title = "Puppy (large image)" picFace.src = "FaceLarge.jpg" End Sub title src Sub End document picFace click btnPuppy_OnClick

Mark Dixon Page 22 Question: Assignment Which of the following are valid: document.bgColor = document.bgColor = "red" "red" = document.bgColor document = "red" btnRed = "Hello"    

Mark Dixon Page 23 Example: Ball Character (design) Trigger (when)Actions (what) click event of Right buttonmove ball character right click event of Left buttonmove ball character left click event of Up buttonmove ball character up click event of Down buttonmove ball character down

Mark Dixon Page 24 Absolute Positioning change properties – change position picBall.style.posTop picBall.style.posLeftpicBall.width picBall.height document.body.clientwidth

Mark Dixon Page 25 Example: Ball Character (script) Ball Character Sub Window_OnLoad () picBall.style.posLeft = 200 picBall.style.posTop = 100 End Sub Sub btnRight_OnClick () picBall.style.posLeft = picBall.style.posLeft + 10 End Sub Sub btnDown_OnClick () picBall.style.posTop = picBall.style.posTop + 10 End Sub

Mark Dixon Page 26 Substitution Right hand side of assignment (after = sign) –contains expressions (calculations)

Mark Dixon Page 27 Example: Sound Sound <object id="sndPlayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="width:0px; height:0px;"> Sub btnFart_onClick() sndPlayer.URL = "Fart.wav" End Sub

Mark Dixon Page 28 Tutorial Exercise: Setup LEARNING OBJECTIVE: to change your computer's settings so that Visual Studio works properly TASK 1: Enable active content in Internet Explorer: 1.1 Start Internet Explorer 1.2 Click the Tools Menu 1.3 Click the Internet Options Item 1.4 Click the Advanced tab 1.5 Ensure 'Disable Script Debugging' is unchecked 1.6 Ensure 'Allow active content on My Computer' is checked 1.7 Click the OK button 1.8 Close Internet Explorer TASK 2: Ensure Visual Studio uses the correct settings. 1.1 Start Visual Studio If it asks you to set the environment settings, choose Visual BASIC settings 1.3 Click the Start Visual Studio button

Mark Dixon Page 29 Tutorial Exercise: Colour Change LEARNING OBJECTIVE: to understand objects, events, properties, and event handler procedures, so that you can create dynamic content in your web-pages TASK 1: Get the Red button from the Colour Change example working. (the code is provided) TASK 2: Get the Blue button working. (You will need to work out what code to use. Use the code provided as inspiration) TASK 3: Add another button (you choose the colour).

Mark Dixon Page 30 Tutorial Exercise: Puppy LEARNING OBJECTIVE: to understand objects, events, properties, and event handler procedures, so that you can create dynamic content in your web-pages TASK 1: Get the Puppy example working. (code provided, images in resources area on server). TASK 2: Add a button, which changes the image back to the smaller picture.

Mark Dixon Page 31 Tutorial Exercise: Ball Char LEARNING OBJECTIVE: to understand objects, events, properties, and event handler procedures, so that you can create dynamic content in your web-pages TASK 1: Get the Right and Down buttons from the Ball Character example working. (code provided, images in resources area on server). TASK 2: Get the Left and Up buttons working. (You will need to work out what code to use. Use the code provided as inspiration) TASK 3: Make the Ball Character blink when the user moves the mouse over it. (You will need to add code that changes the picture) TASK 4: Add a button to move the Ball Character diagonally. (You will need two lines of code in the same event handler)