AxWebBrowser and JavaScript,

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?
 
C

Chris Soulsby

Its the onclick event the <A onclick="javascript:Toggle(this)">

Then in the scripting bit:

function Toggle(node)
{
...
}
 
G

Gordon Truslove

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;
 
C

Chris Soulsby

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top