Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:04:15+00:00 2026-05-24T02:04:15+00:00

In my IE BHO I create a input button element using: var button =

  • 0

In my IE BHO I create a input button element using:

    var button = doc.createElement("input");
    button.setAttribute("value", "myButton"); //next line gets an error
    button.addEventListener("click", openFunction, false); //openFunction is a function inside of the same class

When I try to call button.addEventListener I get a ‘mshtml.IHTMLElement’ does not contain a definition for ‘addEventListener’ error. I find this odd because according to this site (http://help.dottoro.com/ljeuqqoq.php) I should be in the clear.

I also saw this thread but it seems like overkill for what I’m trying to do and I can’t get it to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:04:15+00:00Added an answer on May 24, 2026 at 2:04 am

    Finally got it to work. Had to use similar method to the thread I linked in original question.

    /// Inside the BHO.cs file and in my namespace
    /// Generic HTML DOM Event method handler.
    ///
    public delegate void DHTMLEvent(IHTMLEventObj e);
    
    ///
    /// Generic Event handler for HTML DOM objects.
    /// Handles a basic event object which receives an IHTMLEventObj which
    /// applies to all document events raised.
    ///
    public class DHTMLEventHandler
    {
        public DHTMLEvent Handler;
        HTMLDocument Document;
    
        public DHTMLEventHandler(HTMLDocument doc)
        {
            this.Document = doc;
        }
        [DispId(0)]
        public void Call()
        {
            Handler(Document.parentWindow.@event);
        }
    }
        public void BrowserEventHandler(IHTMLEventObj e)
        {
            try
            {
                if (e.type == "click" && e.srcElement.id == "IDOfmyButton")
                {
                    // do something.
                    something();
                }
            }
            catch
            {
            }
    
        }
    

    Inside my OnDocumentComplete method (also in same namespace as above [extra info for novices]):

                DHTMLEventHandler myHandler = new DHTMLEventHandler(framedoc);
                myHandler.Handler += new DHTMLEvent(this.BrowserEventHandler);
                button.onclick = myHandler;
    

    A lot of work just to get a button to click. In firefox it was one line :O

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my BHO to listen to onmousedown event of some element in a
I have a [ComRegisterFunction] that I am using to register a BHO Internet explorer
I am writing a BHO, the code using IHTMLDocument2::get_scripts to get all script body
I'm trying to develop an Internet Explorer 7 addon using Browser Helper Objects (BHO).
I need to create a BHO in C#. Any documentation available other than the
I writing IE add-on and I'm using ATL for it. I need to create
I am using IE 8, and the IE Developer Toolbar BHO is not working
How does Chromeframe install without admin privileges? If I wanted to create a BHO
I am writing an extension for IE using C# and Windows Forms / BHO
I am creating a BHO using helloworld sample. Building Browser Helper Objects with Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.