Integrating JavaScript and HTML

Slides:



Advertisements
Similar presentations
Microsoft Expression Web-Illustrated Unit K: Working with Behaviors.
Advertisements

Creating and Editing a Web Page Using Inline Styles
Using Advanced Cascading Style Sheets
Chapter 5 Creating an Image Map
Microsoft Office 2007 Excel Web Feature Creating Web Pages Using Excel.
Microsoft Office 2007 Excel Web Feature Creating Web Pages Using Excel.
Creating and Editing a Web Page
Creating a Form on a Web Page
Microsoft Office 2007 Word Web Feature Creating Web Pages Using Word.
Microsoft Office 2007 PowerPoint Web Feature Creating Web Pages Using PowerPoint.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Microsoft Office 2007 Access Integration Feature Sharing Data Among Applications.
HTML Comprehensive Concepts and Techniques Second Edition Project 8 Integrating JavaScript with HTML.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Word Web Feature Creating Web Pages Using Word.
Creating Tables in a Web Site Using an External Style Sheet HTML5 & CSS 7 th Edition.
Creating Tables in a Web Site.  Define table elements  Describe the steps used to plan, design, and code a table  Create a borderless table to organize.
HTML Concepts and Techniques Fourth Edition Project 3 Creating Web Pages with Links, Images, and Formatted Text.
HTML Comprehensive Concepts and Techniques Third Edition Project 3 Creating Web Pages with Links, Images, and Formatted Text.
HTML Concepts and Techniques Fourth Edition Project 8 Creating Style Sheets.
Creating Tables in a Web Site
HTML, XHTML, and CSS Chapter 12 Creating and Using XML Documents.
Project 1: Creating a Dreamweaver Web Page and Local Site 1 Project Objectives Add a background image Open and close panels Display and describe the Property.
Microsoft Office 2007 PowerPoint Web Feature Creating Web Pages Using PowerPoint.
Creating and Editing a Web Page using HTML IMED1316.
Creating and Editing a Web Page Project 2. Project Objectives Project 2: Creating and Editing a Web Page 2 Identify elements of a Web page Start Notepad.
Integrating JavaScript and HTML5 HTML5 & CSS 7 th Edition.
HTML Concepts and Techniques Fourth Edition Project 6 Using Frames in a Web Site.
HTML, XHTML, and CSS Chapter 8 Adding Multimedia Content to Web Pages.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Adobe GoLive Edit and FTP your web pages to a web server.
HTML Concepts and Techniques Fourth Edition Project 7 Creating a Form on a Web Page.
HTML Concepts and Techniques Fourth Edition Project 12 Creating and Using XML Documents.
Creating a Form on a Web Page
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Chapter 1 Creating a Dreamweaver Web Page and Local Site
Microsoft Access 2010 Chapter 10 Administering a Database System.
HTML Comprehensive Concepts and Techniques Third Edition 2 nd Project Creating and Editing a Web Page.
HTML Concepts and Techniques Fourth Edition Project 5 Creating an Image Map.
Using Frames in a Web Site Project 6. Project Objectives Project 6: Using Frames in a Web Site 2 Define terms related to frames Describe the steps used.
HTML Concepts and Techniques Fifth Edition Chapter 4 Creating Tables in a Web Site.
HTML Concepts and Techniques Fifth Edition Chapter 3 Creating Web Pages with Links, Images, and Formatted Text.
1 After completing this lesson, you will be able to: Get around the Internet with your browser. Connect to the Internet. Print Web pages. Save Web pages.
Creating and Editing a Web Page
Creating and Editing a Web Page Using Inline Styles
Creating Web Pages with Links, Images, and Embedded Style Sheets
XP New Perspectives on Creating Web Pages With Word Tutorial 1 1 Creating Web Pages With Word Tutorial 1.
Project 1 Creating a Dreamweaver Web Page and Local Site.
Creating and Editing a Publication
Introduction to Microsoft Windows XP
Using DHTML to Enhance Web Pages
PowerPoint Web Feature
Project 8 Creating Style Sheets.
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Creating Tables in a Web Site Using an External Style Sheet
Office 2010 and Windows 7: Essential Concepts and Skills
Chapter 2 Adding Web Pages, Links, and Images
Using Frames in a Web Site
Creating Web Pages with Links, Images, and Formatted Text
Objectives Use Help and Support Copy, move, rename, and delete files
Creating Tables in a Web Site
Project 5 Creating an Image Map.
New Perspectives on Windows XP
Introduction to Internet Explorer
DREAMWEAVER 8 Creating a Dreamweaver Web Page and Local Site.
Presentation transcript:

Integrating JavaScript and HTML Chapter 9 Integrating JavaScript and HTML

Chapter Objectives Describe JavaScript and how it can be integrated with HTML Describe how the <div> tag container is used to display text Describe a valid JavaScript user-defined function Write the code to create a <script> section on a Web page Chapter 9: Integrating JavaScript and HTML

Chapter Objectives Define and describe JavaScript variable Extract the current system date Calculate the number of days from the current date to a future date Use the innerHTML property to display a dynamic message to a Web page Chapter 9: Integrating JavaScript and HTML

Chapter Objectives Write a user-defined JavaScript function that changes the color of the browser’s scroll bar Write a user-defined JavaScript to open a Web page from a <select> tag <option> value Use the lastModified property to display the date the document was last modified Use an event handler to invoke a JavaScript user-defined function when a Web page is loaded Chapter 9: Integrating JavaScript and HTML

Opening an Existing HTML File Start Notepad++, and, if necessary, maximize the window Click View on the menu bar. If the Word wrap command does not have a check mark next to it, click Word wrap With a USB flash drive plugged in to your computer, click File on the menu bar and then click Open on the File menu Navigate to the Chapter09\ChapterFiles folder on the USB drive Double-click chapter9-1.html in the list of les to display the HTML code for the chapter9-1.html Web page Chapter 9: Integrating JavaScript and HTML

Opening an Existing HTML File Chapter 9: Integrating JavaScript and HTML

Entering a <div> Tag Container Click the blank line at line 41 and type <div id=“displayDate”> and press ENTER Type </div> and do not press ENTER Chapter 9: Integrating JavaScript and HTML

Entering a <div> Tag Container Chapter 9: Integrating JavaScript and HTML

Entering the Start <script> and Comment Tags In the Notepad++ file chapter9-1.html, click line 9 (a blank line) Type <script type=“text/ javascript”> as the beginning of the script and then press the ENTER key Type <!--Hide from old browsers and then press the ENTER key to put the insertion point on line 11 Chapter 9: Integrating JavaScript and HTML

Entering the Start <script> and Comment Tags Chapter 9: Integrating JavaScript and HTML

Extracting the Current System Date Using the Date() Object If necessary, activate the Notepad++ window. If necessary, click line 11 below the <!--Hide from old browsers statement Enter the JavaScript code shown in Table 9–15, indenting as shown. Press ENTER at the end of each complete line of code. If the current year is different from 2012, replace 2012 with the current year in the indexOf() method on line 19 After typing the last line in Table 9–15, press the ENTER key twice to leave space for additional JavaScript code Compare what you typed to Figure 9–5. Correct any errors before proceeding Chapter 9: Integrating JavaScript and HTML

Extracting the Current System Date Using the Date() Object Chapter 9: Integrating JavaScript and HTML

Calculating the Number of Days to a Future Date If necessary, click line 22 Enter the JavaScript code shown in Table 9–17 on the previous page. Enter the current year’s Columbus Day date in line 22, if necessary. Press ENTER at the end of each complete line of code After typing the last line in Table 9–17, press the ENTER key twice Compare what you typed to Figure 9–6. Correct any errors before proceeding Chapter 9: Integrating JavaScript and HTML

Calculating the Number of Days to a Future Date Chapter 9: Integrating JavaScript and HTML

Displaying Text and Variable Values to a Web Page Using innerHTML Click line 26, if necessary Enter the JavaScript code shown in Table 9–19 to create the message text with the stored values Press the ENTER key only at the end of each complete line of code. Press the ENTER key once more after the last } in Table 9–19 to leave a blank line between user-defined functions Chapter 9: Integrating JavaScript and HTML

Entering the User-Defined Function to Change the Browser Scroll Bar Color If necessary, click blank line 29 Enter the JavaScript code shown in Table 9–21 Press the ENTER key twice after the last } to leave a blank line between user-defined functions Chapter 9: Integrating JavaScript and HTML

Click line 35 if necessary Entering the User- Defined Function to Link to a New URL Using the Drop-Down Menu List Click line 35 if necessary Enter the JavaScript code shown in Table 9–24 to enter the options and links for the drop-down menu list Press the ENTER key twice after line 39 Chapter 9: Integrating JavaScript and HTML

Entering the User-Defined Function to Link to a New URL Using the Drop-Down Menu List Chapter 9: Integrating JavaScript and HTML

Including the Date Last Modified and a Copyright Message in a Text String Scroll down and click line 124 Enter the JavaScript code In Table 9–26. Do not press the ENTER key after the last line Scroll up and click line 41 Enter the JavaScript code shown in Table 9–27 Press the ENTER key after each line, and press the ENTER key twice after the } in line 45 Chapter 9: Integrating JavaScript and HTML

Including the Date Last Modified and a Copyright Message in a Text String Chapter 9: Integrating JavaScript and HTML

Entering the End Comment and </script> Tags If necessary, click blank line 47 Enter the JavaScript code shown in Table 9–28 and do not press the ENTER key after the last line Chapter 9: Integrating JavaScript and HTML

Associating User-Defined Functions with the onload Event Click to the right of the y in the <body> tag in line 75 Press the SPACEBAR once and then type onload= scrollColor(); countDown(); copyRight()” within the <body> tag. Do not press the ENTER key Chapter 9: Integrating JavaScript and HTML

Associating User-Defined Functions with the onload Event Chapter 9: Integrating JavaScript and HTML

Associating a User-Defined Function with the onchange Event Scroll to line 113 and click to the right of “Menu” Press the SPACEBAR once and then type onchange= “loadInfo(this. form)” within the <select> tag. Do not press the ENTER key Chapter 9: Integrating JavaScript and HTML

Associating a User-Defined Function with the onchange Event Chapter 9: Integrating JavaScript and HTML

Saving an HTML File With a USB drive plugged into your computer, click File on the menu bar and then click Save As to display the Save As dialog box Type chapter9-1solution.html in the File name text box (do not press the ENTER key) Click Computer in the left-hand side of the dialog box to display a list of available drives If necessary, scroll until your USB drive, such as UDISK 2.0 (G:), appears in the list of available drives If necessary, open the Chapter09\ChapterFiles folder Click the Save button in the Save As dialog box to save the le on the USB ash drive with the name chapter9-1solution.html Chapter 9: Integrating JavaScript and HTML

Saving an HTML File Chapter 9: Integrating JavaScript and HTML

Testing the Completed Web Page Open Internet Explorer and type g:\Chapter09\ChapterFiles\chapter9-1solution.html in the Address box Press ENTER to display the Web page. If a security message appears, click that bar, click the Allow Blocked Content option that displays, and then click Yes in the confirmation dialog box Select October PTO in the drop-down menu list to display the October PTO Web page Click the Back button on the Standard Buttons toolbar to return to the Oakwood Elementary School home page Select State Achievement Test in the drop-down menu list to display the State Achievement Test Web page Click the Back button on the Standard Buttons toolbar to return to the Oakwood Elementary School home page, and select October Fundraiser from the drop-down menu list to display the October Fest Fundraiser Web page Chapter 9: Integrating JavaScript and HTML

Testing the Completed Web Page Chapter 9: Integrating JavaScript and HTML

Validating a Web Page Open Internet Explorer and navigate to the Web site validator.w3.org Click the Validate by File Upload tab Click the Browse button Locate the chapter9-1solution.html file on your storage device and click the file name Click the Open button on the Choose File to Upload dialog box and the file name will be inserted into the File box Click the Check button Chapter 9: Integrating JavaScript and HTML

Printing an HTML File Click the Notepad++ icon on the taskbar and click the chapter9-1solution.html tab to activate the file Click File on the menu bar and then click Print. Click the Print button in the Print dialog box Chapter 9: Integrating JavaScript and HTML

Quitting Notepad++ and a Browser In Notepad++, click the File menu, then Close All Click the Close button on the Notepad++ window title bar Click the Close button on all open browser windows Chapter 9: Integrating JavaScript and HTML

Chapter Summary Describe JavaScript and how it can be integrated with HTML Describe how the <div> tag container is used to display text Describe a valid JavaScript user-defined function Write the code to create a <script> section on a Web page Chapter 9: Integrating JavaScript and HTML

Chapter Summary Define and describe JavaScript variable Extract the current system date Calculate the number of days from the current date to a future date Use the innerHTML property to display a dynamic message to a Web page Chapter 9: Integrating JavaScript and HTML

Chapter Summary Write a user-defined JavaScript function that changes the color of the browser’s scroll bar Write a user-defined JavaScript to open a Web page from a <select> tag <option> value Use the lastModified property to display the date the document was last modified Use an event handler to invoke a JavaScript user-defined function when a Web page is loaded Chapter 9: Integrating JavaScript and HTML

Integrating JavaScript and HTML Chapter 9 Complete Integrating JavaScript and HTML