is a method of
Well, let's say we wanted to get somebody's name before they saw our page,
and then write their name on our web page right before their very eyes.......Well,
with a space for the viewer to answer. The second set of quotes allows
us to enter any default answer. If we leave it blank, the viewer will
just see an empty box ready to be typed in. This is usually done before
the webpage loads, so that we can write the answer they give into our page.
are in the HEAD
section, while the actual writing of the name
occurs in the BODY section of webpage.
The first thing that happens is that the
will be a string of characters that makes up
the person's name. The if/else statement assigns enteredname
a value of
"Dude" if nothing is entered in the prompt by the user. It checks for " "
and for null, and both are pretty much nothing. Now, in the BODY section,
We will also see a new command called document.write(" ")
; . This is what allows
to be written onto the
We are writing two strings plus our variable, enteredname
is not in quotes because it is a value and not itself a string but it's value is a
string. That's why we have the plus signs around it....It makes the browser write
plus the second string. Now, notice the
tags back to the page is by including them inside the quotes as part of the string.
Also, we probably noticed the way the closing tags were written differently. (<\/H1>).
forward slash without it being mistaken for a division sign! (Remember / is division in
our single forward slash. Pretty nifty trick, isn't it?
Well, that does it for now. Let's go check out the above code and examine and
analyses in reality,