Introduction to Javascript
So you want to learn Javascript? You may already know HTML or XHTML and you want to move on to something more interactive, or you may have heard about Javascript and are curious about it, or one of many other reasons. Whatever your reason(s) may be, Javascript is a great language to learn!
This lesson focuses on:
- What you should already know
- What is Javascript?
- Javascript and Java
- What can be done with Javascript?
What you should already know
Before studying Javascript, you should already have at least a basic understanding of HTML and/or XHTML. Javascript scripts are placed on webpages with HTML/XHTML tags and without knowing these tags, you will not know where and how to place Javascript scripts on a webpage. If you need to study HTML, you can do so at our HTML section. If you need to study XHTML, you can do so at our XHTML section.
What is Javascript?
Javascript is a scripting language developed by Netscape used to provide dynamic and interactive content on webpages. It is one of the first scripting languages in existence and today is the most popular scripting language on the web. Javascript works in all modern web browsers including Firefox, Netscape, Opera, and Internet Explorer.
Javascript and Java
Javascript, Java, what's the difference? A major difference!!
There exists a common misconception that Javascript and Java are the same language. They are not. Javascript is a scripting language used to create dynamic and interactive content on webpages, while Java is a high level, object-oriented, platform independent programming language developed by Sun Microsystems. Java can be used to write software applications as well as applets that run in web pages.
What can be done with Javascript?
There is alot you can do with Javascript:
-
Interact with the user
Interact with the user. For example, you can ask the user for their name in a prompt box and print a custom message with it on a webpage such as "Hello Roger!"
-
Form validation
Validate data entered by the user. For example, you can check to make sure that certain fields in a form were actually filled out, or that a piece of data contains the required amount of characters.
-
Browser detection
Detect what web browser a user is using. For example, you can find out if a user is using Netscape or Firefox.
-
Read and write cookies
A cookie is a small text file stored by a website on a users hard drive. With Javascript, you can create cookies to store on a users hard drive and later read them. For example, you can store a users preference for the background color of a webpage in a cookie, and every time the user visits your website again you can read the cookie that stores this value and set the background color to the users preference accordingly.
-
Act upon events
Specify code to run when certain events occur. For example, when the user clicks a button you can instruct Javascript to display a message in an alert box.
All this and much more can be done with Javascript!




