website template
Besides properties and methods, there is
one web templates more very important concept in JavaScript:
events, and that's the next topic in our JavaScript survey.
Dynamic HTML makes your Web pages come alive and allows
you to respond to the user's actions.
website templates But how do you know when such an action
has occurred? For example, what if you want to change
the color of a Web page when the user clicks that page?
To inform you when something's web site templates happened,
JavaScript uses events, such as mouse clicks. When the
user clicks the page, a mouse down event occurs. free
templates To handle that event, many H¥ML tags now
support events. You use the onMouseDown event attribute
when the mouse is clicked in a Web page's body. Here's
an example showing one way of responding to such events.
free website templates In this case, I'll change the document's
background color to red when the mouse is clicked:"OK,"
says the novice programmer, "I've gotten JavaScript
to display a welcome message, free web templates but that's
not too powerful. How can I start storing some data?"
"Pull up a chair," you say, "and we'll
go through it." JavaScript recognizes
free website templates several
types of data: numbers, Boolean values, text strings,
functions, and objects. Boolean data holds values of true
or false, we'll discuss functions in the Immediate Solution's
"Creating Functions" section, and we've already
seen objects.
cool templates
JScript, on the other hand, recognizes six types of data:web
templates numbers, text strings, objects, Boolean values,
null, and undefined. The null type simply holds a value
of 0, and the undefined type website templates indicates
that the data has not been assigned a value. So how do
you store data values in JavaScript?
free web templates As with
other programmingweb site templates languages, you use
variables. A variable is simply
the name of a memory location in which you can store data
and access it later. To create a free templates variable
in JavaScript, you use the var statement. After you've
created the variable, you can store data of the type JavaScript
can free website templates handle in that variable. In
this, I'm creating a variable named number with the var
statement Next, I'm assigning that variable theweb site
templates value of 366 with the assignment operator. Now
when I use the name number, JavaScript will replace it
with the value in that variable, so I can display the
number of days in the year 2000 like this: You can use
the mouse in the Web page itself, and the code will report
the location of the mouse when an event occurs and whether
the Ctrl, Shift, or Alt key is down.
I'll add a hyperlink to the
page as well to show how the onMouseOver (occurs when
the mouse is over an element) and onMouseOut (occurs when
the mouse leaves an element) events work.
|
|