Top Banner
Writing a JavaScript User-Defined Function A function is JavaScript code written to perform certain tasks repeatedly Built-in functions
21

Writing a JavaScript User-Defined Function A function is JavaScript code written to perform certain tasks repeatedly Built-in functions.

Dec 31, 2015

Download

Documents

Roland Melton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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

A function is JavaScript code written to perform certain tasks repeatedly

Built-in functions

Page 2: 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

Page 3: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Page 4: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Page 5: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 6: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

Type <SCRIPT LANGUAGE=“JAVASCRIPT””>and then press the ENTER key. Type

<!—Hide from old browsers and thenpress the ENTER key

Page 7: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 8: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Page 9: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

Saving the File

Click Save on the File menu

Page 10: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 11: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Page 12: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Page 13: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 14: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

Click Print

Page 15: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.
Page 16: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

Closing Notepad and Your Browser

Click the Close button on the browser title bar

Click the Close button on the Notepad window title bar

Page 17: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 18: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 19: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

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

Page 20: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

What You Should Know

Page 21: Writing a JavaScript User-Defined Function  A function is JavaScript code written to perform certain tasks repeatedly  Built-in functions.

Project 8 Complete

PLEASE REVIEW FOR EXAM!