Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Internet Explorer
Methods
 fireEvent method
fireEvent method

[This documentation is preliminary and is subject to change.]

Fires a specified event on the object.

Syntax

object.fireEvent(bstrEventName, pvarEventObject, )

Standards information

There are no standards that apply here.

Parameters

bstrEventName [in]

Type: BSTR

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.
JavaScriptObject that specifies the event object from which to obtain event object properties.
pfCancelled [out, retval]

VARIANT_TRUE (true)

Event fired successfully.

VARIANT_FALSE (false)

Event was canceled.

C++Boolean that receives one of the following values:
JavaScriptBoolean. Returns one of the following values:

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Type: BooleanVARIANT_TRUEtrue

Event fired successfully.

VARIANT_FALSEfalse

Event was canceled.

Boolean. Returns one of the following values:Boolean that receives one of the following values:

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 propertyValue
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

 

 

Build date: 3/14/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
fireEvent isn't fully implemented      Page Notes   |   Edit   |   Show History

Following GMariani's tip, I attached fireEvent to a paragraph element and tested it against the all of the event names IE recognizes. For 59 of the event names, fireEvent returned true. For the following 20 events names, fireEvent returned the Invalid Argument error:

onabort onafterprint onbeforeprint onbeforeunload onbounce onchange onerror onfinish onhashchange onload onmessage onoffline ononline onreset onselect onselectionchange onstart onstop onsubmit onunload

When I used fireEvent to trigger onmouseover, it returned false.

Tags What's this?: Add a tag
Flag as ContentBug
Simulating Mouse Click on a Client Side Image Map      john jst   |   Edit   |   Show History
I need to simulate a mouse click on a client side image map. Which object should invoke the fireEvent()? It cannot be simply the <area> object since it could be referenced by 2 different <img>'s. It cannot be the <img> since we need a way to tell which part of the img is clicked which is defined in the <area> tag?

I've done some test with real mouse click on an client side image map. The event object generated from my click indicates (by the window.event.srcElement property) the event is generated from <area> tag. But when I tried to programmatically call the <area>'s fireEvent(), nothing happened!

Does IE actually support simulating click on a client side image map?
Tags What's this?: Add a tag
Flag as ContentBug
Firing Events      GMariani   |   Edit   |   Show History
Why can't you fire an onChange event from the DIV tag?
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker