www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
Methods
 createEventObject Method
createEventObject Method

Generates an event object to pass event context information when you use the fireEvent method.

Syntax

oNewEvent = document.createEventObject( [oExistingEvent])

Parameters

oExistingEvent Optional. A object that specifies an existing event object on which to base the new object.

Return Value

Returns an event object.

Example

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"  style="height:200;width:200;padding:50;background-color:mistyrose">
<div id="Inner"  style="height:100;width:100;padding:25;background-color:lavender"></div>
</div>
</body>
</html>

Standards Information

There is no public standard that applies to this method.

Applies To

document
Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG