What is JavaScript?
JavaScript is commonly used today in
website pages. It is a scripting language that adds functionality
to website pages. JavaScript is similar to Java, but they
are not the same. It is basically a smaller version of Java
and that JavaScript is simplified, it isn't complicated and
the source code is placed within a website pages HTML (HyperText
Markup Language) document. Many web designers use JavaScript
to enhance their website pages, adding functionality and interesting
page elements.
Where did it come from?
JavaScript was originally developed
by Brenden Eich with Netscape. When JavaScript was under development,
it was named LiveScript. Netscape and Sun Microsystems put
together a licensing deal and with that, the 'Java' part of
the name was added into it.
Since JavaScript and Java are completely
different, a person can program JavaScript and not know how
to program Java or vice-versa. It is important that one grasps
the concept that these two languages are different and completely
separate, not to get the two confused. JavaScript can be a
good learning tool as a pre-cursor language to learn prior
to learning Java as the two do share some common syntax elements.
Meaning since JavaScript is easier to learn than Java it may
be a benefit for some programmers to learn JavaScript first
and ease their way into learning Java.
Why would a website use JavaScript?
JavaScript can be used to enhance website
pages, add functionality and interesting page elements. Have
you ever went to a website that had a drop-down menu? Drop
down menus can be created with a combination of JavaScript,
CSS (Cascading Style Sheets) and HTML 4.0, this combination
of web programming is known otherwise as DHTML (Dynamic HyperText
Markup Language). The addition of CSS and JavaScript along
with the HTML gives the drop-down menu the functionality.
(There are other ways to do drop down menus, but DHTML is
a common way.)
JavaScript can add immediate interaction
from your users. You can do something as simple as asking
someone their name and then customizing the content to address
them personally. (Hence, the JavaScript interacts with the
HTML of the page and allows for some dynamic page content.)
JavaScript can also be applied to images
and content (also known as DHTML techniques) so that images
roll-over on a navigation bar or when someone moves their
mouse over an element the content of the page appears or disappears.
This is commonly done with DHTML layering.
Some people view websites as being
boring without animations, flash, java applets, and intractability
of the website users.
Without writing server-side code (such
as VB.NET, C#, PHP...etc.), JavaScript can validate forms.
On form submission of lets say a contact form, it can check
and see if the phone number has enough characters, or if an
email looks like it is valid, it can check and see if all
of the required fields are filled in and give the user an
error prompt if something needs to be fixed, added or changed.
This allows for some customization with the content of the
form, giving it usability and interaction that otherwise it
wouldn't have had.
I've even seen JavaScript used (in
combination with CSS and HTML 4.0 - DHTML) so that images
and text can be moved by the website user on the page. By
clicking on an image or on a word, the object could be moved
around the page and placed wherever the user feels fit to
leave the object.
Since JavaScript can perform if-statements,
a website can be tailored to individual website visitors using
JavaScript. An if-statement is common in programming; they
are used for checking case, variables, all different types
of statements... For example you could display a message special
for anyone named 'Mary'. An if-statement may look like this:
Functionality Concerns of JavaScript
JavaScript is not cross-platform, meaning
that not all browsers fully support JavaScript and the ones
that do generally allow their users the ability to turn off
JavaScript functionality. Different browsers will read the
JavaScript code a little differently than others and some
won't support it at all! Due to the wide variety of browsers
that users have the ability of installing and using, the amount
of browsers is increasingly expanding. Many users never upgrade
their browsers that come with their computers and others insist
on using other browsers. The only way that this could ever
improve is that if everyone got rid of their old browsers
and upgraded to the latest and greatest browsers out on the
market - although even that won't solve the problems with
the discrepancies of how browsers read and interpret code.
Don't let this stop you!
Yes it is true that old browsers definitely
do not have the same scripting support that the newer browsers
do and it is true that even the new browsers will read code
differently. There is a wealth of information online to help
get past the quirks in the different browsers.
I would suggest that if you want to
add JavaScript functionality to your website, do it. Just
don't implement JavaScript in a way that would block users
that don't have JavaScript abilities on their browser. With
that said, add JavaScript to enhance a website, don't make
all of the content rely on JavaScript behavior or else you
may be disappointed to learn that your website does not show
content on all browsers as you may have otherwise expected.
How do I enable JavaScript?