33 JavaScript Coding examples
33 JavaScript Coding examples
For each of the examples below you will need to click on the example to display the results from the code.
When the results are displayed in your browser click view and then Source to see the source code.
To test out Javascript for yourself try this handy bit of code: The Javascript tester
01) Dialog box - How to create a dialog box.
02) On Mouse over - How to use the on mouse over event along with image swapping.
03) Dynamic menu - How to create a simple drop down list and button, along with dynamic control of links.
04) Java script in HTML - How to include a script area in an HTML document.
05) Javascript comments - How to include comments in a javascript section of a HTML document.
06) Assignments - Assignment to a variable in Javascript.
07) Operators - Use of operators in javascript.
08) Expressions - Expressions and typing
10) If then else syntax - A simple example of the if then else syntax.
11) For loop - A simple example of a for loop.
12) While loop - A simple example of a while loop
13) Another loop - Another loop example.
14) Nested loop - Nested loop example
15) Function - A function definition and call example
16) Function with parameters - A function with parameters definition and call example.
17) Function with return - A function with parameters and a return values plus a nested loop that creates a table.
18) Arrays - The use of arrays in javascript.
19) Average - Array example with manipulation of the array values.
20) Records - Objects and arrays.
21) Reference - A lesson in defining objects.
22) Window types - This code illustrates different window types available from Javascript. These include an alert box, a confirmation window, and an input prompt, along with the opening of a second window.
23) Accessing the browser history list - Use javascript to access the next and previous values from the browsers history list.
24) An animation - A simple animation example using javascript.
25) Frames - Frames and communication between them.
26) Forms - A simple calculator. Shows how to use forms, links fields and create a result based on other input fields
27) Scrolling text in status line - How to scroll text across the window status line.
28) Upper case - Force text in a field to upper case
29) New window creation - Create a window with specific attributes
30) Set Browser home page - Set a default home page for the browser from javascript. Only works with IE5.
31) Digital Clock - An example of the use of a timer.
32) Valid dates - Validation of dates in HTML forms
33) Colour fade - Fade from one colour to another onload
Retirado de: www-k12.atmos.washington.edu/~ovens/javascript/jsindex.html em fev2014