http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/fireevent.asp

Fires a specified event on the object.

Syntax

<!----> bFired  =  object.fireEvent(sEvent [,oEventObject])
Parameters
sEventRequired. String that specifies the name of the event to fire.
oEventObjectOptional. 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

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

分享到:
评论