AxSHDocVw.AxWebBrowser

  • Thread starter Thread starter Kristof Thys
  • Start date Start date
K

Kristof Thys

First, I hope this is the correct newsgroup for my problem. My apologies
if it isn't so.


The AxWebBrowser is driving me crazy at the moment.

In my application I want to catch all the clicked links from the user
and give new meanings to it. The html-pages contain javascript and css
but as far as I understand this isn't a problem.

This is how I try to do it:

In the load of my form:

Object o = null;
axWebBr.Navigate("about:blank", ref o, ref o, ref o, ref o);
theHtmlDocument = (mshtml.IHTMLDocument2)axWebBr.Document;
theHtmlDocument.write(m_HtmlGenerator.GetTaskList(158,true));

Where m_HTMLGenerator generates an HTML string.

This document is shown fine in the browser.

When a user clicks a link, I presume "private void
axWebBr_BeforeNavigate2(object sender,
AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2Event e)" is called.
In there I want to change the document to e.g. the result of
m_HTMLGenerator.GetTaskList(158,false)...

I've tried doing this via:
theHtmlDocument.write( m_HtmlGenerator.GetTaskList(158,false));

or

mshtml.IHTMLElement body = (mshtml.IHTMLElement)theHtmlDocument.body;
body.innerHTML = HTMLString;
(wich seems wrong because the <header> isn't changed)

....


The axWebBr_BeforeNavigate2 function seems to be called twice when the
user clicks a hyperlink. I don't see why.

Does anyone have experience in doing such things,
or is there any documentation on this subject? I would really like to
know how this browser works exactly and what events are raised at what
time....


thanks for any help,

Kind Regards,

Kristof Thys
 
I trap the BeforeNavigate2 event to grab the Url of the link from the
EventArgs. But in my application, I am always canceling the event which
cancels the link. Then I handle the Url in my own manner. Perhaps you could
do something similar? You can't change the Url that is passed because the
arg is ByVal; thus the values you receive are local to you.
 
Back
Top