Help!
for Javascript
This
document contains some hints on using JavaScript in your web
pages. JavaScript is a programming language designed to add
functionality to HTML. You do not have to know anything about
programming to understand this document. However, some knowledge
of HTML is helpful, especially if you are planning on reading
further documentation. What
is it and where did it come from?
Can
everyone use it?
Learning
JavaScript
What
is it and where did it come from?
JavaScript
commonly refers to client-side JavaScript, a programming language
developed by Netscape. Microsoft also has its own version, called
JScript. Other things that have similar names: Java, a cross-platform
programming language developed by Sun Microsystems, and server-side
JavaScript, similar to CGI script and not supported by our server.
JavaScript
is written directly into your HTML document, and can control
which images are displayed on your web page, or display a message
customized to each visitor to your web page, or do a number of
other things that can make your pages more interactive.
Can
everyone use it?
There
are versions of JavaScript, just like there are versions of browsers.
Older browsers support older versions of JavaScript, or don't
support it at all. In addition, Microsoft's Internet Explorer
can take a piece of JavaScript code and interpret it differently
than Netscape Navigator does. In general, you need Netscape Navigator
2 or later, Internet Expolorer 3 or later, or the AOL browser
version 4 or later to be able to use JavaScript. If you're interested
in a lot of detail about Javascript/JScript implementation in
different browsers, go to: http://www.digitalroom.net/javascript/index.html and http://www.mozilla.org/docs/web-developer/
Some
browsers do not support JavaScript at all, such as text browsers.
In order to hide your script from these browsers, enclose your
script within HTML comment tags:
<!--
Hide your script from old browsers
alert("Good thing you don't have one of those old browsers")
// End hiding script from old browsers -->
You
may also want to provide content for people using browsers that
do not support JavaScript by using the <NOSCRIPT> tag:
<NOSCRIPT>
Text browsers rock! They just don't make browsers like they used to...
</NOSCRIPT>
You
can see what your page will look like through a browser that
doesn't support JavaScript by going to:
http://www.delorie.com/web/wpbcv.html
You must provide a URL for the page, which means that it must be uploaded
to the Wellesley www server (using Fetch or WS_FTP) before you can view it.
Make sure the script box is unchecked, and hit the "view page" button.
Learning
JavaScript
Netscape
maintains a manual describing everything you ever wanted to know
(and more) about JavaScript 1.3 at:
http://developer.netscape.com/docs/manuals/js/client/
jsguide/index.htm
It's a pretty old document, but still useful.
After
you've read that manual, you can instantly acquire years of experience
and avoid code faux pas by reading "Javascript Best
Practice":
http://www.irt.org/articles/js169/#4
For
the less technically inclined, Dreamweaver writes
scripts for you using what it calls "Behaviors". Use
the behaviors dialog box to indicate what you want to happen
at given events. It is also fairly common practice to trade scripts
and credit the origin of the script within an HTML or JavaScript
comment. The authors of a book on JavaScript maintain a companion
web site so that you can copy their scripts:
http://www.chalcedony.com/javascript/
JavaScript
and assorted interactive features are bundled together in an
acronym: DHTML (dynamic HTML). Try a search for DHTML in a
popular search engine and you'll have enough reading
material for a lifetime.
Questions
? Ask Us !
Back
to the Publishing a Web Site home page
|