JavaScript Primer
This is a very basic JavaScript primer. It should get you going in a
matter of minutes. There's a lot more you can do with JavaScript...this
is only meant to get true beginners started.
To start a script inside an HTML document
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<SCRIPT LANGUAGE="JavaScript">
<!-- This hides the script
.
.
.
// This stops hiding -->
</SCRIPT>
If the script is in another document
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<SCRIPT LANGUAGE="JavaScript" SRC="path_to_file">
After the </SCRIPT> you can add a message for those without JS capability
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<NOSCRIPT>
Sorry, you don't have JavaScript
</NOSCRIPT>
Basic Commands
-=-=-=-=-=-=-=
document.write("Writes to HTML document - Can be HTML")
document.writeln("Same as above, but adds a return")
var varName="string"
var varName = 324
var varName //Defines a variable
function funName() { //Defines a function
//Code
}
alert("Message") //Displays an alert...user can just click OK
confirm("Message") //Displays a Yes/No prompt and returns a boolean
prompt("Msg","Def") //Prompts for text with an inital value of Def
NOTE: You can set varnames to function calls and the value returned will be
stored.