navigation
Thomas Brunt's OutFront Hosting
 
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

An Introduction to JavaScript
by OutFront moderator JohnT


Welcome to the first in a series of lessons in JavaScript from Outfront Moderator John T. This series of lessons is meant to teach JavaScript to the beginner.  

We have all seen JavaScript in action while surfing the web.  The image flips (known as image rollovers) on web pages are done with JavaScript.  Also, things like alert messages, date and time displays, pop-up windows, form confirmation pages, scrolling text, browser detection and many other functions are performed with JavaScript.  A recent study indicates that nearly 90 percent of the top 500 websites (based on traffic) use JavaScript.

JavaScript enables the web developer to add dynamic functionality to a web page.  JavaScript is a powerful scripting language that is also capable of performing extensive form data collecting and form processing functions.

There is a major difference between JavaScript and Java. JavaScript may be directly incorporated into web page HTML, and
runs through a browser.  Java cannot be written directly into HTML. Java is a more complex programming language where code is first written, then put through a compiler.  JavaScript was developed by Netscape, whereas Java was developed by Sun Microsystems. The languages share some similarities, but are quite different.

JavaScript is an object-orientated scripting language.  This means that actions are performed on objects such as windows and documents.  We refer to a method as performing an action on an object.  Therefore in JavaScript, we write object.method, in that order.  As you will see during our lesson series, the ordering of the elements in JavaScript is very important.  JavaScript is a very logical scripting language.  I believe that it is this logical progression that makes JavaScript easy to learn.

Well, let’s begin with our first JavaScript.  We will start with a JavaScript that simply writes some text to a page.  Let’s construct a script that writes Learning JavaScript with John T is easy and interesting to a web page.  The script is given below:

<script language=”JavaScript”>
document.write(“Learning JavaScript with John T is easy and interesting”);
</script>


Let’s examine our script in detail.  We need to first tell the browser that a JavaScript is about to follow.  So we do this by the
<script language=”JavaScript”> command.  We told the browser that the script was ending by using the </script> command. 
All right, then it stands to reason that the document.write command writes the text to the page.  Document is the object,
and write is the method being performed on the object. The text that is included in quotations within the parentheses is written to the page.  Text in a document.write command must always be in parentheses.  We also need to tell the browser that the line of JavaScript is ending. We do that by adding a semicolon at the end of the line.

Try it out for yourself.  Since most of you are FrontPage users, open up a new page in FrontPage, go to the HTML tab, and drop the script in between the <head> </head> tags.  Then view the page with the Internet Explorer or Netscape browser to see the script in action.

JavaScript is often placed in between the <head> and </head>, but not always.  As we will see in future lessons, placement varies based on the type of script and the script’s function.  In our next lesson we will also discuss the comment tags that you have most likely seen before (a very popular comment tag that starts with <!--).

Well, that is all for our first lesson and brief introduction to JavaScript.  I look forward to our next lesson.

----------> 
John T.
SailingWays Web Services
http://www.sailingways.com/design

Part II >>


 

Fun With Background Images
Fun With Bulleted Lists
Are You Compliant?
Introduction To Cascading Style Sheets
Creating Custom Error Pages
Designing Fast Loading Sites
Creating Funky Forms With CSS
htaccess Magic
An Introduction To JavaScript
JavaScript Snippets
Getting More From Mailto
Installing And Using Perl Scripts
Preparing Photos For Your Web Site
The Popup Dilemma
Paint Shop Pro Album 4
Creating And Using robots.txt File
Creating JavaScript Rollover Buttons

Microsoft Corporation in no way endorses or is affiliated with "OutFront." 
OutFront is published and edited by Thomas Brunt
440 Great Circle Dr., St. Matthews, SC 29135.  803-655-6151
© 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 All Rights Reserved
Click here to view our privacy statement.