to home page





This last updated line is coded by JavaScript

JavaScript comes from the stables of Netscape. JavaScript is one of the commonest scripting languages used on the net and it is really easy to use.

Essentially it is interpreted language in that doesn't need to be translated or compiled its reader simply executes each line as it comes to it (much like a moviescript).

The reader in JavaScript's case (no prizes for guessing) is your browser (most modern browsers are "JavaScript enabled").

The JavaScript is simply written into the HTML

Lets look at our clock

<script language="JavaScript">
document.write("<i>"+"Last Updated -"
+document.lastModified + "</i>");
<noscript>sorry you need to be JavaScript Enabled to see this

JavaScript is embedded in an HTML document between <script> tags, but the actual Script lies between the comment tags (<!-- and -->)

With a Javascript enabled browser the <script> tabs warn it to look for the Java in between these (non enabled browsers treat it just as a comment so nothing is displayed).

Note the // indicate the start and end of the script. The script itself is dead easy. The document.write tells the browser to write the info contained in the brackets with the document.lastModified showing the HTML file's last modified time.

We've added <noscript> tags for rare or older non JavaScript enabled browsers (it won't appear if you have JavaScript enable one)

Here's another working example in the next line of text

In HTML this is coded as this-

<script language ="JavaScript">
<!-- ();
document.write("If your browser is Javascript enabled it can see this");
<noscript>sorry you need to be JavaScript Enabled to see this

You can write some very complex and powerful Scripts

Here JavaScript is used to process a form for calculating a car loan.
Just fill in the left column and use press on the "work it out" button

Please not this is a fun example and not a serious form for calculating car loans

Car Purchase Plan
Total Car Price ()
Deposit ()
Annual Interest Rate: %
Loan Length Years
The costs
Outstanding loan ()
No of Payments Months
Deposit ()
Monthly Cost ()

back to the top

Many sites on the web can teach you how to write JavaScript. You can also find examples on this site and on the web to copy and paste into your HTML documents. Check our Cool Tips and links for some starting points. As with everything check the copyright and as mentioned be wary with JavaScript (although little evidence of any real dangers!!)

Java is another important language used in web design. Unlike JavaScript rather than running from a script on the page an addition file called an applet contains the program. If you haven't done so take a look at our Java Applet page for more.back to the top

Back to advanced menu
Back To Advanced HTML