Share via


event Property

As it applies to the FPHTMLScriptElement and IHTMLScriptElement objects.

Returns a String that represents the name of the event handler for which a script is written.

expression.event

*expression   * Required. An expression that returns one of the above objects.

As it applies to the FPHTMLWindow2 and IHTMLWindow2 objects.

Returns an IHTMLEventObj object that represents a user action that occurs on a document, window, or element within a document.

expression.event

*expression   * Required. An expression that returns one of the above objects.

Example

As it applies to the FPHTMLScriptElement object.

The following example sets the event attribute to the onmousemove event for the first SCRIPT element in the active document.

Dim objScript As FPHTMLScriptElement

Set objScript = ActiveDocument.Scripts.Item(0)
objScript.event = "onmousemove"

As it applies to the FPHTMLWindow2 object.

The following example displays a message every time the user clicks on the active document telling whether the user is pressing the SHIFT key. This example must be placed in a class module, and it assumes that you have declared in the General Declarations section of a class module an FPHTMLDocument object variable called "doc" using the WithEvents keyword.

Private Function objDoc_onclick() As Boolean
    Dim objEvent As IHTMLEventObj

    Set objEvent = Window.event
    
    Select Case objEvent.shiftKey
        Case False
            MsgBox "You are not pressing your SHIFT key."
        Case True
            MsgBox "You are pressing your SHIFT key."
    End Select
End Function

Applies to | FPHTMLScriptElement Object | FPHTMLWindow2 Object | FPHTMLWindowProxy Object | IHTMLScriptElement Object | IHTMLWindow2 Object