AxWebBrowser and JavaScript,

  • Thread starter Thread starter Chris Soulsby
  • Start date Start date
C

Chris Soulsby

Hi,

I'm displaying a html page in the AxWebBrowser web control. The html
contains some JavaScript. When I run this in IE it all works fine,
however, when I run it in AxWebBrowser I get a "object expected"
scripting error when a click event is raised.

Can anyone help?
 
Its the onclick event the <A onclick="javascript:Toggle(this)">

Then in the scripting bit:

function Toggle(node)
{
...
}
 
Not totally sure what you're doing but:
try this...

instead of
el.innerHTML = this.Html;
try
el.location = "about:"+this.Html;

you can also run javascript in the browser from a c# app by doing this..
el.location = "javascript:"+SomeScipt;
 
I've solved the problem :-)

The problem was that I was setting the html like this:

mshtml.IHTMLElement oIHTMLElement = null;
mshtml.IHTMLDocument2 oIHTMLDocument2 =
(mshtml.IHTMLDocument2)this.Document;
oIHTMLElement = oIHTMLDocument2.body;
el.innerHTML = m_strHtml;

This was not setting up the scripting and style sheet stuff. The answer was
to used the write method on the document. For example:

mshtml.IHTMLDocument2 oIHTMLDocument2 =
(mshtml.IHTMLDocument2)this.Document;
oIHTMLDocument2.write(strHtml);

Thanks for all the help.

Chris
 
Back
Top