Hmm, well it's a workaround but maybe one of you OLE gurus could tell me the proper way to do it? Thanks.
 
In my HTML document, a JavaScript function:
 
function GetEventObject() {
document.all('event_id').innerHTML = window.event.srcElement.id;
document.all('event_type').innerHTML = window.event.type;
}
 
and some *hidden* span tags with the respecitve ID attributes: event_id and event_type. Okay, in my Perl code:
 
sub DocumentComplete {
    $ie->Document->{onclick} = Win32::OLE->Forward(sub {
    $ie->Document->parentWindow->execScript('GetEventObject()', 'JavaScript');
    print $ie->Document->All('event_id')->{innerHTML}, " : ", $ie->Document->All('event_type')->{innerHTML}, "\n";
    });
}
 
The goal is to create a Perl event handler that can handle bubbled events from the HTML document. This will work if I add the JavaScript function and HTML to every document but it's not a clean solution. I want my Perl handler to be independent of the web sites content (HTML).
 
Much obliged to anyone who might share the appropriate Perl code to obtain the event object.
 
Thank you,
Michael  % )

 
----- Original Message -----
Sent: Wednesday, April 24, 2002 8:36 AM
Subject: Win32::OLE & Browser Event Object

Hi,
 
The code snippet below works great but unlike Javascript I am not receiving the "event object" in my Perl onclick event handler. What I need is a Perl onclick handler to handler all clicks on the page. In Javascript I would write something like:
 
    window. {
    alert window.event.srcElement.id; // This gives me the ID attribute of the HTML element clicked  : )
    }
 
In Perl/Win32::OLE I'm wondering if I can get the same value somehow, maybe like this?
 
    Win32::OLE->WithEvents($ie, 'BrowserEvents', 'DWebBrowserEvents2');
    package BrowserEvents;
 
    sub DocumentComplete { 
        $ie->Document->{onclick} = Win32::OLE->Forward(sub {
            print $ie->Window->Event->srcElement->{id};
        });
    }
 
Thank you very much for any assistance. I don't want to execute a JavaScript function to populate some HTML elements to get the information in a round about way but I could I guess.
 
Michael

Reply via email to