Javascript Examples

This page demonstrates some basic Javascript techniques, but to complete HW 16 and get full credit you have to make your own page, not just copy this one. You will also have to add another Javascript effect beyond the ones demonstrated here (see the HW 16 requirements).


Load

When the page loaded, it changed the background color to aqua, using this script in the HEAD section:
<SCRIPT language="JavaScript">
<!-- hide from old browsers
document.bgColor='aqua';
//-->
</SCRIPT>
Note: This one does not work in Firefox.

Mouseover

Point here to make the background yellow. Here's the script:
<A HREF="" onMouseover="document.bgColor='yellow'">here</A>
Point here to make the background aqua again.

Button

Several buttons are shown below with their source code:

<FORM>
<INPUT type="button" value="Click to see an alert"
onClick="alert('Alert! Click OK to continue.')">
</FORM>
<FORM>
<INPUT type="button" value="Click to make text blue"
onClick="document.fgColor='blue'">
</FORM>
<FORM>
<INPUT type="button" value="Click to make text black"
onClick="document.fgColor='black'">
</FORM>
<FORM>
<INPUT type="button" value="Click to change status bar"
onClick="window.status='Awesome!'">
</FORM>
Note: This one does not work in Firefox.


Links for Other Techniques

Last modified 5-14-05