fireEvent Method Internet Development Index --------------------------------------------------------------------------------Fires a specified event on the object.SyntaxbFired = object.fireEvent(sEvent [, oEventObject]) ParameterssEvent 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 ValueBoolean. Returns one of the following values:true Event fired successfully. false Event was cancelled. ResIf 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 property Value cancelBubble false returnValue true srcElement element on which the event is fired type name of the event that is fired ExampleThe following sample shows how to use the fireEvent method.HideExample<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>
它肯定有那个事件
另外一个
按钮中的 onclick事件指向的方法不行吗?
除了不能获取点击时的事件对象外,别的应该都没有影响。
ParameterssEvent 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 ValueBoolean. Returns one of the following values:true Event fired successfully.
false Event was cancelled. ResIf 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 property Value
cancelBubble false
returnValue true
srcElement element on which the event is fired
type name of the event that is fired
ExampleThe following sample shows how to use the fireEvent method.HideExample<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>