PowerPoint Presentation - Writing a JavaScript User

Download Report

Transcript PowerPoint Presentation - Writing a JavaScript User

Writing a JavaScript
User-Defined Function
 A function is
JavaScript code
written to perform
certain tasks
repeatedly
 Built-in functions
Writing a JavaScript
User-Defined Function
 User-defined functions
 Written by the Web developer
 Functions can have data passed to it
 To call a function means to have
JavaScript execute the function
Entering the chngSite() User-Defined
Function in the HEAD Section
 Click the blank line (line 4) between the
end </TITLE> tag and the end </HEAD>
tag
Type <SCRIPT LANGUAGE=“JAVASCRIPT””>
and then press the ENTER key. Type
<!—Hide from old browsers and then
press the ENTER key
Entering the chngSite() User-Defined
Function in the HEAD Section
 Press the SPACEBAR four times. Type function
chngSite() { and then press the ENTER key. Press
the SPACEBAR eight times. Type alert(“You are
about to be transported to the new site
location!”) and then press the ENTER key. Press the
SPACEBAR eight times. Type location =
“http://www.scsite.com/” and then press the
ENTER key. Press the SPACEBAR four times. Type }
and then press the ENTER key. Type //-> and then
press the ENTER key. Type </SCRIPT> and then press
the ENTER key
Saving the File
 Click Save on the File menu
Testing the Web Page
 Click the Fun with Phonics button on the
taskbar
 Click the Refresh button on the browser
toolbar
 If you are connected to the Internet, click the
OK button when the dialog box displays with
the alert message
 Click the Back button on the browser toolbar
to return to the Fun with Phonics Web page
Printing the HTML File
Using Notepad
 If necessary, click the Notepad button
on the taskbar. Click File on the menu
bar and then point to Print
Click Print
Closing Notepad and Your
Browser
 Click the Close button on the browser
title bar
 Click the Close button on the Notepad
window title bar
Summary





Discuss how to integrate JavaScript with HTML
Insert <SCRIPT> tags on a Web page
Write start and end <SCRIPT> tags
Define and use flickering to draw attention
Describe the background color property of the
document object
Summary
 Set the background color of a Web page using
JavaScript
 Save the HTML file
 Test the Web page
 Discuss JavaScript variables
 Extract the system date
 Use several variables to construct a message
Summary
 Describe the write() method of the document object
 Write a user-defined function that displays a
message and links visitors to a new Web site
 Describe how the setTimeout() method works
 Use the lastModified property to display the last
modified document date
 Print an HTML Notepad file
What You Should Know
Project 8 Complete
PLEASE REVIEW FOR EXAM!