Generates an event object for passing event context information when using the fireevent method.
dhtml语法
onewevent = document.createeventobject( [oexistingevent])
parameters
oExistingEvent |
Optional.
Object that specifies an existing event object on which to base the new object. |
Return Value
Returns an event object.
DHTML代码范例
The following sample shows how to use the createEventObject method with the fireEvent method.
<html>
<body>
<script>
function OuterClick() {
if(event.expando == "from_inner")
{
alert("Event actually fired by clicking on inner DIV!")
}
else
{
alert("Event fired by clicking on outer DIV!")
}
}
function InnerClick() {
var eventObj = document.createEventObject();
// Set an expando property on the event object. This will be used by the
// event handler to determine what element was clicked on.
eventObj.expando = "from_inner";
parent.document.all.Outer.fireEvent("onclick",eventObj);
event.cancelBubble = true;
}
</script>
<div id="Outer" onclick="OuterClick()" style="height:200;width:200;padding:50;background-color:mistyrose">
<div id="Inner" onclick="InnerClick()" style="height:100;width:100;padding:25;background-color:lavender"></div>
</div>
</body>
</html>
是否符合公共标准
There is no public standard that applies to this method.
Applies To