Left Quote    If at first you don't succeed, redefine success.
- Anon.    
Right Quote
[login] | [Register]

Learning JavaScript Basics

by: bs0d
Page: 10 of 10
(View All)


If you plan on involving JavaScript a bit more in your Web Pages, you can set the background and foreground colors using JavaScript. The foreground will be the color of the text on your webpage. The built-in functions below will set these properties:

  • fgColor: Set your foreground like this, document.fgColor="red";
  • bgColor: And set the background like this, document.bgColor="green";

You can either set the colors using the name of the color, or you can use the hexadecimal format. I am sure you have seen them before, but here is an example anyway...

Keyboard Events

The most common keyboard event used is the onkeypress event. This even can check to see if a key is pressed on the keyboard. Here's a list of some keyboard events.

  • onkeypress - Detects a keypress from the keyboard.
  • keyCode - Records the ASCII value of a letter pressed on the keyboard.
  • onkeydown - This event is triggered when a key has been pressed down.
  • onkeyup - Is triggered when a key from the keyboard is released.

These keyboard events can get quite interesting if you're familiar with the ASCII values of the key's on the keyboard. Check out this code sample:

In order for this to work, press the capital "A" and the textbox will indicate you doing so. If you were to press anything else, the program would not work.


I feel that by now I have covered a wide range of the basics of programming in javascript and writing your own programs. You could go into more detail of each topic covered, but the intent is to introduce you to it, and it will be up to you to follow through with the language. I hope that the extra code samples and the sample code programs did provide additional understanding of the concepts. Javascript is relatively easy to learn and can be quite useful for your Web Pages. I hope that you found this tutorial helpful on your way to learning something new.

-bs0d |

1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  10  |  

No Comments for this page.

You Must be logged in or a member to comment.

Tutorial Stats

Tutorial Stats

3 Total Comments
4.66 Rating of 5 (3 Votes)


Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article



· Getting Started with Ajax
Your Article Here

"" Copyright © 2002-2020; All rights lefted, all lefts righted.
Privacy Policy