Java & Javascript Library

Java Applets and JavaScript Because Java applets are platform-independent, Stiletto's Virtual Server System is quite capable of supporting pre-compiled Java classes. JavaScript is also supported.

Java and JavaScript Collection

Stiletto has selected some very functional applets and provided easy to follow installation instructions for its customers.

onAbort image
onClick button, checkbox, radio, link, reset, submit, area
onFocus select, text, testarea
onMouseOver link, area
onMouseOut link, area
onSelect text,text area
onSubmit form
onReset form
onBlur select, text, text area
onChange select, text, text area
Non-interactive event handlers
handler used in
onError image
onLoad windows, image
onUnload window
onAbort

An onAbort event handler executes JavaScript code when the user aborts loading an image.

Example:


<HTML>

<HEAD>
<TITLE> Example of onAbort Event Handler </TITLE>

</HEAD>


<BODY bgcolor="ffffff">

<H3>Example of onAbort Event Handler:</H3>
<STRONG>Stop the loading of this image 
and see what happens:</STRONG><BR><>
<IMG  SRC="http://www.stiletto.com.au/images/stilettored.gif" 
onAbort="alert('You stopped loading the image!')">
</body>
</HTML>

Here, an alert() method is called using the onAbort event handler when the user aborts loading the image.

onClick
In an onClick event handler, a JavaScript function is called when an object in a button (regular, radio, reset and submit) is clicked, a link is pushed, a checkbox is checked or an image map area is selected. Except for the regular button and the area, the onClick event handler can return false to cancel the action. For example,


<INPUT TYPE="submit" NAME="mysubmit" VALUE="Submit" onClick="return
confirm(`Are you sure you want to submit the form?')">


Note: With Microsoft Windows, the onClick event handler does not work with
reset buttons.

Example: <HTML> <HEAD><TITLE> Example of onClick Event Handler</TITLE> <SCRIPT LANGUAGE="JavaScript"> function valid(form){ var input=0; input=document.myform.data.value; alert("Hello " + input + "! Welcome..."); } </SCRIPT> </HEAD> <BODY BGCOLOR="FFFFFF" TEXT="000000"> <H3>Example of onClick Event Handler</H3> Click on the button after entering your name into the text box:<BR> <form name="myform"> <input type="text" name="data" value="" size=10> <INPUT TYPE="button" VALUE="Click Here" onClick="valid(this.form)"> </form> </BODY> </HTML>

In this example, when the user clicks the button "Click Here", the onClick event handler calls the function valid().

onFocus
An onFocus event handler executes JavaScript code when input focus enters the field either by tabbing in or by clicking but not selecting input from the field. For windows, frames and framesets the event handler executes JavaScript code when the window gets focused. In windows you need to specify the event handler in the <BODY> attribute. For example,


<BODY BGCOLOR='#ffffff' 
onFocus="document.bgcolor='#000000'">

Note: With Microsoft Windows, the onFocus event handler does not work with <FRAMESET>.

Example:


<HTML>
<HEAD><TITLE> Example of onFocus Event Handler </TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<H3>Example of onFocus Event Handler</H3>
Put your mouse into the text box:<BR>
<form name="myform">
<input type="text" name="data" value="" 
size=10 onFocus="alert('You focused the textbox!!')">
</form>
</BODY>
</HTML>

In the above example, when you put your mouse on the text box, an alert() message displays a message.

onMouseOver
JavaScript code is called when the mouse is placed over a specific link or an object or area from outside that object or area. For the area object the event handler is specified with the <AREA> tag. For example:


<MAP NAME="mymap">
<AREA NAME="FirstArea" COORDS="0,0,49,25" 
HREF="mylink.htm"
onMouseOver="self.status='This will take you to mylink.htm';
return true">
</MAP>


Example: <HTML> <HEAD><TITLE> Example of onMouseOver Event Handler </TITLE> </HEAD> <BODY BGCOLOR="FFFFFF" TEXT="000000"> <H3> Example of onMouseOver Event Handler</H3> Put your mouse over <A HREF="nw-onmouseover-javascript.htm" onMouseOver="window.status='Hello! How are you?' ; return true;"> here</A> and look at the status bar. </BODY> </HTML>

In the above example when you point your mouse to the link, the text "Hello! How are you?" appears on your window's status bar.

onMouseOut
JavaScript code is called when the mouse leaves a specific link or an object or area from outside that object or area. For area object the event handler is specified with the <AREA> tag.

Example:



<HTML>
<HEAD><TITLE> Example of onMouseOut Event Handler </TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<H3>Example of onMouseOut Event Handler</H3>
Put your mouse over <A HREF="java/nw-onm~2.htm" 
onMouseOut="window.status='You left the
link!' ; return true;"> here</A> 
and then take the mouse pointer away.
</BODY>
</HTML>

onSelect
A onSelect event handler executes JavaScript code when the user selects some of the text within a text or textarea field.

Example:


<HTML>
<HEAD><TITLE> Example of onSelect Event Handler </TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<H3>Example of onSelect Event Handler</H3>
Select the text from the text box:<br>
<form name="myform">
<input type="text" name="data" value="Select This" size=20
onSelect='alert("This is an example of onSelect!!")'>
</form>
</BODY>
</HTML>

In the above example, when you try to select the text or part of the text, the alert method displays the message, "This is an example of onSelect!!"

In the above example, after pointing your mouse and leaving the link , the text "You left the link!" appears on your window's status bar.

onSubmit
An onSubmit event handler calls JavaScript code when the form is submitted.

Example:



<HTML>
<HEAD><TITLE> Example of onSubmit Event Handler </TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<H3>Example of onSubmit Event Handler</H3>
Type your name and press the button<BR>
<form name="myform" onSubmit='alert("Thank you " 
+ myform.data.value +"!")'>
<input type="text" name="data">
<input type="submit" name ="submit" 
value="Submit this form">
</form>
</BODY>

In this example, the onSubmit event handler calls an alert() function when the button "Submit this form" is pressed.

onReset
An onReset event handler executes JavaScript code when the user resets a form by clicking on the reset button.

Example:


<HTML>
<HEAD><TITLE> Example of onReset Event Handler </TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<H3>Example of onReset Event Handler</H3>
Please type something in the text box and press the reset button:<BR>
<form name="myform" onReset="alert('This will reset the form!')">
<input type="text" name="data" value=" " size=20 value="" >
<input type="reset" Value="Reset Form" name="myreset">
</form>
</BODY>
</HTML>

In the above example, when you push the button, "Reset Form" after typing something, the alert method displays the message, "This will reset the form!"

onBlur
An onBlur event handler executes JavaScript code when input focus leaves the field of a text, textarea, or a select option. For windows, frames and framesets the event handler executes JavaScript code when the window loses focus. In windows you need to specify the event handler in the <BODY> attribute. For example,


<BODY BGCOLOR='#ffffff' onBlur="document.bgcolor='#000000'">


Note: With Microsoft Windows, the onBlur event does not work with 
<FRAMESET>.

Example: <HTML> <HEAD><TITLE> Example of onBlur Event Handler </TITLE> <SCRIPT LANGUAGE="JavaScript"> function valid(form){ var input=0; input=document.myform.data.value; if (input<0){ alert("Please enter a value that is greater than 0"); } } </SCRIPT> </HEAD> <BODY BGCOLOR="FFFFFF" TEXT="000000"> <H3>Example of onBlur Event Handler:</H3> Try entering a value less than zero:<BR> <form name="myform"> <input type="text" name="data" value="" size=10 onBlur='valid(this.form)'>

</form> </BODY> </HTML>

In this example, 'data' is a text field. When a user attempts to leave the field, the onBlur event handler calls the valid() function to confirm that 'data' has a legal value. Note that the keyword this is used to refer to the current object.

onChange
The onChange event handler executes JavaScript code when input focus exits the field after the user modifies its text.

Example:


<HTML>
<HEAD><TITLE> Example of onChange Event Handler </TITLE>
<SCRIPT LANGUAGE="JavaScript">
function valid(form){
var input=0;
input=document.myform.data.value;
alert("You have changed the value from 10 to " + input );
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000">
<H3>Example of onChange Event Handler</H3>
Try changing the value from 10 to something else:<BR>
<form name="myform">
<input type="text" name="data" value="10" size=10 
onBlur='valid(this.form)'>
</form>
</BODY>
</HTML>

In this example, 'data' is a text field. When a user attempts to leave the field after a change of the original value, the onChange event handler calls the valid() function which alerts the user about value that has been entered.

onError
An onError event handler executes JavaScript code when an error occurs while loading a document or an image. With the onError event you can now turn off the standard JavaScript error messages and have your own function that will trace all the errors in the script. To disable all the standard JavaScript error messages, all you need to do is set window.onerror=null. To call a function when an error occurs all you need to do is this: onError="myerrorfunction()".

Example:


<HTML>
<HEAD><TITLE> Example of onError event handler </TITLE>
<SCRIPT Language="JavaScript">
window.onerror = ErrorSetting

var e_msg="";
var e_file="";
var e_line="";

document.form[8].value="myButton"; //This is the error

function ErrorSetting(msg, file_loc, line_no) {
        e_msg=msg;
        e_file=file_loc;
        e_line=line_no;
        return true;
}

function display() {
        var   error_d = "Error in file: " + e_file +
                            "\nline number:" + e_line +
                             "\nMessage:" + e_msg;
        alert("Error Window:\n"+error_d);

}

</SCRIPT>
</HEAD>

<BODY bgcolor="ffffff" text="000000">
<h3> Example of onError event handler</H3>
<form>
<input type="button" value="Show the error" 
onClick="display()">
</form>
</body>
</HTML>

Notice that the function ErrorSetting() takes three arguments: message text, URL and Line number of the error line. So all we did was invoke the function when an error occured and set these values to three different variables. Finally, we displayed the values via an alert method.

Note: If you set the function ErrorSetting() to False, the standard dialog will be seen.

onLoad
An onLoad event occurs when a window or image finishes loading. For windows, this event handler is specified in the <BODY> attribute of the window. In an image, the event handler will execute handler text when the image is loaded. For example:

Example:


<HTML>
<HEAD><TITLE> Example of onLoad Event Handler </TITLE>
<SCRIPT LANGUGE="JavaScript">
function hello(){
        alert("Hello there...\nThis is an example of onLoad.");
        }
</SCRIPT>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000" onLoad="hello()">
<H3>Example of onLoad Event Handler</H3>
</BODY>
</HTML>

The example shows how the function hello() is called by using the onLoad event handler.

onUnload
JavaScript code is called when a documented is exited. Here's an example of onUnload event handler.


<HTML>
<HEAD><TITLE> Example of onUnload Event Handler </TITLE>
<SCRIPT LANGUGE="JavaScript">
function goodbye(){
        alert("Thanks for Visiting!");
        }
</SCRIPT>
</HEAD>
<BODY BGCOLOR="FFFFFF" TEXT="000000" onUnLoad="goodbye()">
<H3>Example of onUnload Event Handler</H3>
Look what happens when you try to leave this page...
</BODY>
</HTML>

In this example, the onUnload event handler calls the goodbye() function as user exits a document.

Note: You can also call JavaScript code via explicit event handler call. For example say you have a function called myfunction(). You could call this function like this:


document.form.mybotton.onclick=myfunction

Notice that you don't need to put () after the function. The
event handler has to be spelled with lowercase characters.
 

Return to Main Stiletto Menu


Copyright © 1998,Stiletto.
Contact us:
To place an order now call: 0412 050 477
sales@Stiletto.com.aut