Alexander
Alexander

Reputation: 1343

Process JavaScript-generated page in BHO

I'm developing a BHO and need to process page content on OnDocumentComplete event. But I found a problem - there are no page content at that moment, because it is generated later by JavaScript.

I was trying to call myself by using Navigate method with JavaScript function that must call me, but without any success. I've searched by keywords , , and found no useful results.

Thanks for any advices.

EDIT1: Creating a new thread and passing into it pointer to this works fine in development environment, but cause crashes on real system.

EDIT2: Today's workaround - IE tool-bar button IOleCommandTarget::Exec method calls page parsing code. But it requires user interaction.

EDIT3: New workaround - in FinalConstruct I create my own window. If template search fails I create new thread, that sleeps some seconds and sends WM_USER message to that window. Window procedure calls page parser.

Upvotes: 2

Views: 127

Answers (1)

Alexander
Alexander

Reputation: 1343

Just to close the issue. Today's solution is to handle most of event that can be fired by IE:

BEGIN_SINK_MAP(CVIEBHO)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE,   CVIEBHO::OnDocumentComplete)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE,   CVIEBHO::OnDownloadComplete)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_ONQUIT,             CVIEBHO::OnQuit)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2,    CVIEBHO::BeforeNavigate2)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2,  CVIEBHO::NavigateComplete2)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_PROPERTYCHANGE,     CVIEBHO::PropertyChange)
    SINK_ENTRY_EX(1071, DIID_DWebBrowserEvents2, DISPID_PROGRESSCHANGE,     CVIEBHO::ProgressChange)
END_SINK_MAP()

Inside of my code I check against the URL witch type of event may occur for the current page and do parsing inside this event handler.

TWIMC - Latest Update

Currently working events are:

  • OnDownloadComplete
  • OnDocumentComplete
  • ProgressChange

All other events is not applicable to my goals.

Upvotes: 1

Related Questions