Re: HTML versus JavaScript
by "Ted Temer" <temer(at)c-zone.net>
|
Date: |
Tue, 5 Dec 2000 19:23:30 -0800 |
To: |
"HWGBASICS" <hwg-basics(at)hwg.org> |
|
todo: View
Thread,
Original
|
|
Pam:
> What is the difference between HTML and JavaScript when writing text for
> websites?
>
Everything Dennis said is quite true. JavaScript is a scripting language you
run in a web page to accomplish a task that might be difficult--or
imposable--using HTML alone.
But if the connotation of your question was to ask about the appearance of
the text on a web page--whether it would look different if written in
JavaScript as opposed to plain HTML--the answer would be ...usually not.
Examples:
If you wanted to say "Hi there. How are you?" This is how it would be coded
using plain HTML:
<HTML>
<HEAD>
<TITLE> *** Place Title for Top of Browser Here *** </TITLE>
</HEAD>
<BODY BGCOLOR="white">
Hi there. How are you?
</BODY>
</HTML>
Now let us suppose you wanted to say the same thing but write it with
JavaScript. It might look something like this:
<HTML>
<HEAD>
<TITLE> *** Place Title for Top of Browser Here *** </TITLE>
</HEAD>
<BODY BGCOLOR="white">
<SCRIPT LANGUAGE = JavaScript>
document.write("Hi there. How are you?")
</SCRIPT>
</BODY>
</HTML>
If you copied and saved the two pages, you would see that the end result in
your browser is basically the same. In neither case, was any font
information given so the two tiny sentences should appear in the browser's
default font and be left justified.
The main reason for using JavaScript is to have it "do" something. So if we
took that last script and mixed it in with some plain old HTML and a
function or variable, we could add a touch of pizzazz. Well--sort of ...
<HTML>
<HEAD>
<TITLE> *** Place Title for Top of Browser Here *** </TITLE>
</HEAD>
<BODY BGCOLOR="white">
<center>Hi there. How are you?</center>
<p>Today is
<SCRIPT LANGUAGE = JavaScript>
var today = new Date()
document.write (today)
</SCRIPT>
</BODY>
</HTML>
Here--depending on browser and platform--it will add today's date. And
that's why we add JavaScript--to work with math--detect something and apply
an if-then statement--to make something happen.
Of course, this is over simplified. For more, I suggest the following as the
most'est, easy to understand, step by step, rank beginner type, JavaScript
tutorial I have ever seen. Gosh -- Even I can understand some of it, sort
of...
www.javascriptmall.com/
Once again, sorry to be so brief
Best wishes
Ted Temer
Temercraft Designs Redding, CA
temer(at)c-zone.net
www.temercraft.com/
www.newsredding.com/
HTML: hwg-basics mailing list archives,
maintained by Webmasters @ IWA