Online JavaScript Tutorials

JavaScript tutorials which will help you use javaScripts on your web pages, even beginners. This javascript tutorial also includes links to other programming sites.

Get key press events using JavaScript

Get Key Press Events Using JavaScript
script language="javascript" type="text/javascript"

function CheckPressedKey(Key)

{
switch(KeyID)
{
case 13:
alert("Key Pressed: Enter");
break;

case 16:
alert("Key Pressed: Shift");
break;

case 17:
alert("Key Pressed: Ctrl");
break;

case 18:
alert("Key Pressed: Alt");
break;

case 19:
alert("Key Pressed: Pause");
break;

case 37:
alert("Key Pressed: Arrow Left");
break;

case 38:
alert("Key Pressed: Arrow Up");
break;

case 39:
alert("Key Pressed: Arrow Right");
break;

case 40:
alert("Key Pressed: Arrow Down");
break;
}

}


End script

CheckPressedKey(event)

JavaScript trim function Equivalent of PHP trim Function

This function returns a string with whitespace stripped/removed from the beginning and end of string . Without the second parameter, trim() will strip these characters:

* " " (ASCII 32 (0x20)), an ordinary space.
* "\t" (ASCII 9 (0x09)), a tab.
* "\n" (ASCII 10 (0x0A)), a new line (line feed).
* "\r" (ASCII 13 (0x0D)), a carriage return.
* "\0" (ASCII 0 (0x00)), the NUL-byte.
* "\x0B" (ASCII 11 (0x0B)), a vertical tab.

In PHP we can easily use trim($string) and all whitespace are stripped And in JavaScript we use this function to stripped the White spaces.

function trim(sValue)
{
return sValue.replace(/^\s+|\s+$/g, "");
}

JavaScript Equivalent of PHP Explode Function

In PHP we can easily break a long string into smaller parts by using the explode() function of PHP. In run rime, this function works like this:

$string_to_Explode="JavaScript Equivalent of PHP Explode Function";
$explodestring=explode(" ", $string_to_Explode);

After the execution of the second command the variable $explodestring is an array such that,

$explodestring[0]="JavaScript"
$explodestring[1]="Equivalent"
$explodestring[2]="of"
$explodestring[3]="Explode"
$explodestring[4]="Function"

and so on. So how do we do it in JavaScript. In JavaScript there is a split() function that achieves the same objective, although the syntax is a bit different.

var string_to_explode="JavaScript Equivalent of PHP Explode Function";
var explodestring=string_to_explode.split(" ");


Now the Array explodestring has all those words such that,

explodestring[0]="JavaScript"
explodestring[1]="Equivalent"
explodestring[2]="of"
explodestring[3]="Explode"
explodestring[4]="Function"

Getting Started with Javascript and DOM

I find Javascript is one of those languages that every man has heard about, but not many people know how to use it very well.
View Getting Started with Javascript and DOM Tutorial

How to validate forms with JavaScript

This Tutorial help you how to validate forms with javaScript. Before viewing tutorial Download the required resources
View How to validate forms with JavaScript Tutorial

What is DHTML?

Most web developers don't actually know, or only have a vague idea of what the term means; a consequence of the fact that no official specs or definition have ever been issued. View More

: A Web Site on a single Dynamic HTML file

This method uses 'overlays' which are DIVs, that are styled and filled to create the site content. The visibility and positioning of these DIVs is the primary work of the developer. To accomplish this successfully requires a substantial development editor, because the resulting HTML file, along with the script, will be BIG! Five thousand lines of source code is to be expected. If the development environment is weak, one will crash and burn quite easily. View Dynamic Overlay Tutorial

Create an Analog Clock on your Website Using Javascript

Learn how you can create an Analog Clock on your website using javaScript. View Create an Analog Clock on your Website Using Javascript Tutorial

JavaScript Digital clock

In this article we are going to design a JavaScript based Digital Clock. Here we are see use a HTML Form to show our Digital Clock. View JavaScript Digital clock Tutorial

Fading Button

Move your mouse over the button and watch it fade to another color and then fade back to original color once you move your mouse down. The message on the button will even change after you click on it! View Fading Button Tutorial

Windows Buttons

Make you website button same as your windows buttons View Windows Buttons Tutorials

Creating your own AJAX live preview display simialr to digg

Very similiar to digg's. Alright, this is pretty cool as well as simple. View Ajax Live Preview Display

How to create a complete website entirely from Ajax

This tutorial will tell you how to apply ajax to make a website completely in ajax. It isn't required to know how to use ajax for this tutorial and you could probably apply it without knowing javascipt either. The focus is on the application of ajax to make a website with it. View Create Website in Ajax Tutorial