Share via


addScript Method

Adds a script to an element for a specified event.

expression.addScript(element, event, script, index)

*expression   *Required. An expression that returns one of the objects in the Applies To list.

element   Required IHTMLElement. Specifies the element that receives the action.

event   Required String. Specifies the name of the event that causes the script to run.

script   Required String. Specifies the script that runs when the event occurs.

index   Optional Variant.

Example

The following example inserts a script into the onmouseover event for the first paragraph in the active document:

Dim objPara As FPHTMLParaElement

Set objPara = ActiveDocument.all.tags("p").Item(0)

ActiveDocument.addScript objPara, "onmouseover", "alert('hello!');"

Applies to | FPHTMLDocument Object | IFPDocument Object | IFPDocument Object