Registering an event is basically associating an element (EG: <input ...>) with an event handler (EG: onclick) and its corresponding event handling code (EG: alert('hi');).

NOTE: This page does some funky stuff and does not have valid XHTML.

Registering explicitly means that you can tell the element is connected to a piece of code by looking at the element, whereas registering implicitly means that you have to look outside of the element. Both of the implicit ways can be used in IE to handle custom events (EG: ontimechange()) or events with parameters (EG: onerror(message, url, lineno)).

Explicit Inline Event Handling

Explicit inline event handling has been used since NN2 and IE3, and currently works with NN4, NS6, and IE4. Explicit inline event handling is the only type of event registration that JS 1.0 (NN2) can do, i.e. JS 1.0 cannot do the other kinds of event registration listed on this page.

Here is the syntax:

<tag .... eventHandler="eventHandlerCode">

One or more event handler can be called inline. EG:

<tag .... eventHandler="FunctionCall1(); FunctionCall12();">

One or more events can be called inline. EG:

<tag .... eventHandler1="eventHandlerCode1"           eventHandler2="eventHandlerCode2">

JS 1.1 and NN3 introduced the possibility of reassigning event handlers with this syntax.

object.eventhandler = FunctionReference

IE can assign event handlers with function calls but not with function references/pointers. EG:

document.all.tagXID.onclick ="RunMe()"; //OK
document.all.tagXID.onclick =RunMe;     //Not OK

EG

<form>
<input type="button" value="click b1" id="b1"
       onclick="alert('explicit inline event handling')" />
</form>

Implicit ID_Event Procedures

Implicit ID_event procedures work with IE but not NN4 or NS6.

Here is the syntax:

<script language="VBScript">
Sub elementID_eventHandler()
    ...
End Sub
</script>

This works in .

EG

This script goes in the header:

<script language="VBScript">
<!--
Sub b2_OnClick()
  MsgBox "implicit ID_event procedure"
End Sub
' /-->
</script>

This is the element:

<form>
<input value="click b2" type="Button" id="b2" />
</form>

Implicit Named Scripts

Implicit named scripts work with IE but not NN4 or NS6.

Here is the syntax:

<script language="scriptLanguage" for="elementID" event="eventHandler">
    ...
</script>

EG

This script goes in the header:

<script language="VBScript" for="b3" event="onClick">
<!--
MsgBox "implicit named script"
' /-->
</script>

This is the element:

<form>
<input value="click b3" type="Button" id="b3" />
</form>

Page Modified: (Hand noted: ) (Auto noted: )