Fires a specified event on the object.
Syntax
object.fireEvent(bstrEventName, pvarEventObject, pfCancelled)Parameters
- bstrEventName [in]
-
Type: String
String that specifies the name of the event to fire.
- pvarEventObject [in, optional]
-
C++ Pointer to a Variant that specifies the IHTMLEventObj interface from which the event properties are obtained. JavaScript Object that specifies the event object from which to obtain event object properties. - pfCancelled [out, retval]
-
C++ Boolean that receives one of the following values: JavaScript Boolean. Returns one of the following values:
Return value
Type: Boolean
trueEvent fired successfully.
falseEvent was canceled.
Boolean. Returns one of the following values:Boolean that receives one of the following values:Standards information
There are no standards that apply here.
Remarks
If the event being fired cannot be canceled, fireEvent always returns VARIANT_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 property | Value |
|---|---|
| cancelBubble | false |
| returnValue | true |
| srcElement | element on which the event is fired |
| type | name of the event that is fired |
Examples
The following sample shows how to use the fireEvent method.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/fireEventEX1.htm
<html>
<head>
<script type="text/javascript">
function fnFireEvents()
{
oDiv.innerText = "The cursor has moved over me!";
oButton.fireEvent("onclick");
}
</script>
</head>
<body>
<h1>fireEvent Method Sample</h1>
<p>By moving the cursor over the <strong>div</strong> 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></p>
</body>
</html>
See also
- a
- abbr
- 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
- createEventObject
Send comments about this topic to Microsoft
Build date: 1/23/2013