in Education by
I'm working on an extension (BHO) for Internet Explorer, and having trouble attaching a .NET delegate to the mshtml objects to catch DOM events. I've tried using the events published by the IHTMLElementEvents2_Event, ... interfaces, and that works, but only if I specify the correct type for the DOM element whose events I want to catch. I also need to specify in code the type of the element, and this technique doesn't allow for catching custom DOM events. I've also tried using the HtmlEventProxy class, which attaches IDispatch objects to the DOM elements via the IHTMLElement2.attachEvent method, but that isn't working for me at all. When I try to access the event object as described in this thread, I get a hang when accessing the DOM element's document property. So how can I attach event handlers to DOM elements without needing to special case every kind of element and every kind of event? Thanks. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can try this code: [ComVisible(true)] public class Foo { public Foo(HtmlDocument doc) { IHTMLDocument2 doc2 = (IHTMLDocument2)doc.DomDocument; doc2.onkeydown = this; } [System.Runtime.InteropServices.DispId(0)] public void EventHandler() { IHTMLWindow2 win2 = (IHTMLWindow2)_doc.Window.DomWindow; IHTMLEventObj e = win2.@event; if (e.keyCode == (int)Keys.F5) { // ... } } }

Related questions

0 votes
    We have redesigned the structure to a website which has several business units. Now I want to redirect (301 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm writing an app for Android in Xamarin Forms. I want to navigate the user from one page to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have one aspx page with 1000 anchor tag. I want to open single popup onclick of anchor tag & ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I have developed one application in which i have to detect whether user has tapped home button or whether ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I have developed one application in which i have to detect whether user has tapped home button or whether ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    How do I implement a Copy menu item in a Windows application written in C#/.NET 2.0? I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I've created a seperate assembly with a class that is intended to be published through wmi. Then I' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    In my tests I need to test what happens when an OracleException is thrown (due to a stored procedure ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I've got a method that reads settings from my config file like this: var value = ConfigurationManager. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm reading text from a flat file in c# and need to test whether certain values are dates. They ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'm reading text from a flat file in c# and need to test whether certain values are dates. They ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
...