HTML and CSS Reference
In-Depth Information
To Enter a <div> Tag Container
The following step enters the <div> tag with the id attribute. No other tags or text are needed between the
beginning <div> and the closing </div> tag.
line 44 and type
<div id=
and press e n t e r .
Click the blank line at
press ENTER key
at end of line 44,
not line 45
</div> and do
not press e n t e r
(Figure 9-3).
insertion point
Figure 9-3
Writing User-Defined Functions
User-defined functions are normally written in the <head> section so that this
code is loaded before the remainder of the Web page. The user-defined functions in the
Midwest Bridal Expo Web page do the following:
Calculate and display the number of days until the Midwest Bridal Expo.
Placing JavaScript
Functions in the
<head> Section
Always place your
JavaScript functions in
the <head> section to
ensure they are loaded
completely before they
are called.
Change the color of the scroll bar to match the Web page colors.
Display the date the Web page was last modified.•
Create a drop-down menu linking to other Web pages.
The code in the user-defined function in the <head> section is not executed until a
JavaScript statement calls or invokes the function. To call a function means to invoke or
execute the function. The general form of a user-defined function is shown in Table 9-4.
Table 9-4 User-Defined Functions
General form:
function functionName(optional parameters) {
JavaScript Code
where function is the keyword that designates the function, the functionName is the name
of the user-defined function, and the optional parameters represent values or properties
passed to the function that will be used by the function in the JavaScript code. JavaScript
Code represents the statements that execute when the function runs.
function showBrowserName() {
alert(“You are using” +navigator.appname)
function getSum(myform) {
var sum= document.Calculator.Amount1.value+document.Calculator.Amount2.value
Search WWH ::

Custom Search