Well
... you must've known by now that javascript is the
most commonly used scripting language on the
Internet. It really has some hot advantages. So why
not make use of it in your very own website. Read on
and you'll know exactly what to do. Have fun!
JavaScript is a very commonly used
scripting language around the web. You'll easily find
javascript tutorials in every second HTML related
websites. Just when i started to get hang of HTML and
Frames ... out came javascript! I'm not a javascript
expert but i have plenty of websites on the web ....
one of them is really big so i needed to learn a
little Javascript to enhance my pages.
For this i started searching for all
kinds of information on the World Wide Web related to
JavaScript. I downloaded tutorials and read them ...
as a result now i'm atleast aware of what JavaScript
is. As i was designing this website i thought that i
should use a little experience of my own and put up a
JavaScript page written by myself! This page contains
a little intro to JavaScript and some useful scripts
and links for your reference. So lets get started
....
What is JavaScript ?
> JavaScript is Netscape's cross
platform, object based scripting language for client
and server side applications. Client applications run
in a browser, such as Internet Explorer, and Server
applications run on the server. JavaScript lets you
create applications that run over the Internet.
JavaScript was actually originally
called LiveScript by Netscape, who
created it. I view it and Java as the most valuable
tools in a web designer's tool box today. JavaScript
allows you to create interactivity, dynamic
documents, and animation. It was orinally viewed as
something to "Spruce Up" web pages. It is
now viewed as a tool that can do almost anything you
ever wanted to do in the way of interactivity.
JavaScript and Java
> Some people say that Java and
JavaScript are the same because of having similar
names. This point should be clarified that JavaScript
is not Java. They are simliar in some ways but
fundamentally different in others. The JavaScript
language resembles Java but does not have Java's
static typing and strong type checking. JavaScript
supports most of the Java expressions. However both
of them cannot automatically write to the hard disk.
Using
and Running JavaScript
JavaScript usage is simple--you insert
the script in a <SCRIPT>
tag in the document <HEAD>.
You then call the script in the document using a
variety of techniques.
What is needed in order to run scripts written in
JavaScript? You need a JavaScript-enabled browser -
for example the Netscape Navigator (since version
2.0) or the Microsoft Internet Explorer (MSIE - since
version 3.0). Since these two browsers are widely
spread many people are able to run scripts written in
JavaScript. This is certainly an important point for
choosing JavaScript to enhance your web-pages.
Of course you need a basic understanding of HTML
before reading this document. You can find many
really good online ressources covering HTML. Best you
make an online search for 'html' at Yahoo in order to
get more information on HTML.
Simple and Useful Scripts
There are many useful scritps out there,
and I've used quite a few of them on this site.
JavaScripts are often a little bit tougher to find
than their more widely supported cousin, Java
applets. I've attempted to list just quite a few of
the archives here, along with some of the best
scripts I've found.
Just like anything else, don't make scripts appear as
a serperate entity in the page. Use them sparingly,
and make sure that users who don't have a JavaScript
enabled browser will still get some idea of what is
supposed to be there.
Some examples are illustrated below :
Generating a Message
The buttons at the top of this page
are an example of a message generated with
JavaScript. It is really very easy to do. Just
press on this botton:
You can also string buttons together
like I did at the top of this page. Or you could
use a radio button instead of the regular button.
Sometimes regular buttons get too wide and they
definitely give your very poor text control.
How about a series of messages? Try
this button. You'll get three messages in a row.
Enter a message in the box and check
out how your alert message would look.
onMouseOver Examples: Now put
your cursor over the green ball or the phrase and
watch the message that pops up. This can get kind
of annoying.
Confirmation On Click. The button below
will take you to the index page. Watch the
confirmation that comes on when you click the
link. It asks you to make sure that you want to
go to the index page. You can either click an OK
or Cancel button. If you click OK,
you will go to the index page. If you click Cancel,
you will remain here.
Message in the Status
Bar
You can use the two window
properties, status and defaultstatus to display
messages in the browser's status bar at the
bottom of the window. There are normally messages
like "Contacting Host ..." in Netscape
Navigator and "WebSite Found Waiting for
Reply ... " in Microsoft Internet Explorer.
The defaultstatus message
appears when nothing else is in the status bar.
The status property
displays a transient message in the status bar,
such as when the user moves the mouse pointer
over a link.
You can set these properties to
display custom messages. For example, to display
a custom message after the document has finished
loading, simply set defaultstatus. For
example,
defaultstatus = "Some
rise, Some Fall, Some Climb .... to get to
Terrapin"
You could also use it on links.By
default, when the user moves the mouse pointer
over a link the status bar displays the
destination of the link. This can be changed with
the onMouseOver command. For example,
JavaScript document history buttons
allow you to go back and forth within a frame.
The Netscape 2.0 BACK buttons takes you back out
of the frame. You can place these buttons
anywhere on a page just like any form. Sometimes,
for positioning purposes, it helps to put the
form in an invisible table. Try these buttons:
Here is a reload button (it
works but starts you off back at the top of the
page):
You can also add one or more
location buttons. Pressing the middle button will
take you back to the index page. You could make
the middle button anything you want.
Location
Buttons
As shown in the last section, you
can use JavaScript for location buttons such as:
Similarly, you could use radio
buttons for this :
You can also link to locations
within the same page as follows:
You could also clear out the frames
and go to a new location. Press your regular BACK
button to return here.
Email Buttons
Here is a simple e-mail button
preset with a fake e-mail address
(fake@fake.net).This can be used in your webpages
as a replacement of those email images!
More Scripts
Following are some more scripts for you
to download :
Date.txt - A simple
script that displays the date on your page.
Banner.txt - Adds a
little marque effect to your text.
BiggerText.txt - Sort of
amouseover effect, the text grows bigger when the
user passes the mouse pver it.
Counter.txt - A quite cool
javascript. It counts the hits of every single
visitor separately by first asking his/her name.
Fadeout.txt - Fades the
background colour of your page.
Fliptext.txt - A great
example of roll over javascript.
Gradient.txt - A cool
gradient type effect for your text.
Highbutton.txt - Highlights
the button when the mouse passes over it.
Lots.txt - A lot of
things in just one script. Check it out!
Multicheck.txt - Checks
whether the user has left any unentered fields in a
form.
Scripts.txt - Three
scripts in one. First one gives the visitor's browser
and OS info. Second one gives the screen resolution
info and third one is a fade example.
Search.txt - It might
take long if you have a lot of pages but it sure is
cool. You can search your own site with it.
Updateage.txt - A simple
script that you can use for displaying your age. It
changes automatically as you grow up!
Feel free to download and use them in
your website. But i would really thank you if you put
one of the images linking to my site taken from my Link to Me page.