Javascript


<SCRIPT [language="JavaScript]> .... </SCRIPT>


<html>

<head>

<title>The title of the document</title>

<SCRIPT language="JavaScript">

	//functions go here

</SCRIPT>

</head>

<body>

	the main text of the document

<SCRIPT language="JavaScript">

	//some more code goes here

</SCRIPT>

</body>

</html>

Javascript code can be present in any part of a document and is enclosed by the <SCRIPT> tag.

Its probably best to keep the functions in the header part of the document.

Only certain browsers support scripting. Others will simply ignore the <SCRIPT> and </SCRIPT> tags and display the text between them. To prevent this happenning script tags should be embedded in comments:

<html>

<head>

<title>The title of the document</title>

<SCRIPT language="JavaScript">

<!-- 

	//code goes here

// -->

</SCRIPT>



</head>

<body>

	the main text of the document

</body>

</html>

	

Events - the how

onBlur
can be used on select, text, or textarea input fields. When one of these fields loses focus, a blur event is generated.

onChange
like onBlur but this even gets generated if the value was changed before focus was lost

onclick
this event is generated when a button, checkbox, radiobutton or list is clicked.
onFocus
Opposite of onBlur, this event is generated when an input field gets focus either by clicking or by tabbing into
onLoad
event generated When a document (and all its subframes) have finished loading. used in the <BODY> tag <BODY onLoad="window.alert("I've finished loading!")>
onMouseOver
An event is generated evertime the mouse moves over a link. Can be used to display status messages
This text sets the status This text clears the status
onSelect
Event is generated when some text is selected in text object.
onSubmit
Event is generated when submit button is pressed on form. returning false prevents form being submitted
onUnload
event generated when document is exited either by loading a new document or exiting the program. LIke the onLoad event used in the BODY or FRAME tag.