fireEvent

HTML (DHTML)

fireEvent Method

Internet Development Index

Fires a specified event on the object.

Syntax

bFired = object.fireEvent(sEvent [, oEventObject])

Parameters

sEvent Required. String that specifies the name of the event to fire.
oEventObject Optional. Object that specifies the event object from which to obtain event object properties.

Return Value

Boolean. Returns one of the following values:

trueEvent fired successfully.
falseEvent was cancelled.

Remarks

If the event being fired cannot be cancelled, fireEvent always returns true.

Regardless of their values specified in the event object, the values of the four event properties—cancelBubble, returnValue, srcElement, and type—are automatically initialized to the values shown in the following table.

Event object propertyValue
cancelBubblefalse
returnValuetrue
srcElementelement on which the event is fired
typename of the event that is fired

Example

The following sample shows how to use the fireEvent method.

<HTML>
<HEAD>
<SCRIPT>
function fnFireEvents()
{
oDiv.innerText = "The cursor has moved over me!";
oButton.fireEvent("onclick");
}
</SCRIPT>
</HEAD>
<BODY>
<h1>Using the fireEvent method</h1>
By moving the cursor over the DIV below, the button is clicked.
<P>
<DIV ID="oDiv" onmouseover="fnFireEvents();">
Mouse over this!
</DIV>
<p>
<BUTTON ID="oButton" ONCLICK="this.innerText='I have been clicked!'" >
Button</BUTTON>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 5.5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this method.

Applies To

A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, nextID, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, styleSheet, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XML, XMP

See Also

createEventObject