GeoffKnagge.com

Javascript Special Effects

This section is dedicated to achieving all of those special effects that you see on some pages, such as customising the status bar when the mouse moves over an object. This is by no means a guide to Javascript. Javascript is available on Netscape and Internet Explorer, as well as some other browsers. Note that Javascript commands tend to be case sensitive, so type them exactly as they appear!

Events

This page concentrates on "Events" - things that the user does to result in an action, such as moving or clicking the mouse, scrollbars, etc. Events can be used with many HTML objects such as links, forms, and even the document body- I can't be more specific but try it out for yourself on the object of your choice. To assign an action to an event, place the following within the opening tag of the object :
[EventName]="[javascript code] ; return true"
If multiple commands are used, they should be seperated by a semi-colon ( ; ).
For example :onmouseover="document.writeln('Hello World!') ; return true"

Some of the available events are:
Event NameWhere Used; what causes it
onAbortCalled when for some reason the object is not completely loaded, such as the user clicking the stop button.
onBlurOccurs when the frame or form object loses its "focus", because another fame or object was clicked on.
onChangeThis occurs when a form object loses the focus after being modified.
onClickCaused by a mouse click on the object
onDblClickCaused by two mouse clicks in quick succession
onErrorUsually used within a <SCRIPT> tag to give instrutions when the browser finds an error in the script
onFocusA form object or frame gains the focus when it is clicked on.
onKeyDownoccurs when a key is pushed
onKeyPressoccurs when a key is pressed
onKeyUpoccurs when a key is released
onLoadUsed when an object, or the document BODY, is loaded
onMouseDownoccurs when the mouse button is pushed
onMouseMoveoccurs when the mouse is moved
onMouseOutwhen the mouse pointer is moved away, after being over an object
onMouseOverwhen the mouse pointer is moved over an object
onMouseUpoccurs when the mouse button is released
onResetIn forms, when the reset button is pressed
onScrollWhen an object's scroll bars are moved
onSelectIn forms, when an object is selected
onSubmitWhen the form's submit button is pressed
onUnloadUsually used in the BODY tag, called when another page is loaded in place of the current one.

Some Basic Commands

Changing the status bar

window.status='(your custom message)'

opening a new window

window.open ('(file address)','(window name)','toolbar=yes|no,location=yes|no, diectories=yes|no,status=yes|no,menubar=yes|no, resizeable=yes|no,scrollbars=yes|no,width=???,height=???')
NOTE: NO spaces between the list of window attributes!!

changing page being viewed

<BODY onLoad="window.location='(address to load)')"}>
(C)opyright 2001-2008, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy.