Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Event Handling

  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Event Handling

    Hey,

    I have the following function:
    Code:
    headingClicked: function() {
    		alert(window.event);
                    //Delay the execution of this function by 1 second.
    		setTimeout(function() { var that = standardistaTableSorting.that;
    		alert(window.event);				
                    var linkEl = getEventTarget(window.event);
                    .....// futher processing
    		}, 1000);
    window.event holds the details of my current event. When I first call an alert on it it tells me that there is an object there. However, after I enter the function in the setTimeout() the window.event is null.
    Does anybody know why window.event would lose its value in the setTimeout() function? Is there anyway I can keep its value so I can use it?

    Hope someone can help,

    Thanks

    Chris

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    window.event would be set to any other event that occurs after that call?
    possibly even a bubbled event to the next element, body, so forth.
    if you must reuse the current one, you'd need to set it to a local variable and pass it, but even then, because you are pointing to a global object reference, it may not be the Event Object you are seeking
    Code:
    var e = window.event;
    setTimeout(function() {alert(e.srcElement.outerHTML)}, 1000);
    and see if you get the expected element..

  • #3
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    window.event is also IE only. In compliant browsers, the event is passed as the first argument to the handler.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •