Javascript
Javascript was constructed to make small programs in XHTML documents. This also means it's a client side language - it runs on the client (the users PC), not on the webserver. Here's a small example:
<script language=JavaScript> <!-- // Hides the script from older browsers document.write("Hello world!") // End of comment hiding the script from older browsers --> </script>The script tag can appear in both head and body, depending on where it's being used. E.g. functions typically are in the head. The example above don't do much - instead of the sentence "Hello world!" just being in the XHTML document, it's being written from javascript. The next example is more exciting.
<script language=JavaScript> <!-- // Hides the script from older browsers document.write("<table border='1'>") for (i=1; i<11; i++) { document.write("<tr>") for (j=1; j<11; j++) { document.write("<td align='right'>" + i*j + "</td>") } document.write("</tr>") } document.write("</table>") // End of comment hiding the script from older browsers --> </script>Rather than explaining the example above, I'll just say, that this little piece of program can make the small table (all products between 2 numbers between 1 and 10), including the arithmetic, in amazingly few lines.
Concept last updated: 25/08 2003.
Relations
|
Other sources
- Beginning XHTML; Frank Boumphrey, CG, DR, JR, SS, TW - 16 Javascript
- DevGuru JavaScript Index -
- Diverse Javascript eksempler -
- Diverse opgaver - Mouseover
- Eksempler på programmerings-sprog - Javascript
- Javascript tutorial, W3Schools (obl.) -
- Start på Javascript 1.2, eksemplerne -
- Start på Javascript 1.2; Tom Negrino og Dori Smith; IDG -
- Start på Javascript 1.5; eksemplerne (obl.) -
- Start på Javascript 1.5; Jes Nyhus; 1.udgave (obl.) -
- XHTML; Alf - 2.5.2A Javascript