AxWebBrowser and JavaScript,

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Soulsby

    #1

    AxWebBrowser and JavaScript,

    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?
  • Gordon Truslove

    #2
    Re: AxWebBrowser and JavaScript,

    What's in the click event?

    "Chris Soulsby" <chris.soulsby@ sysinx.com> wrote in message
    news:860668f9.0 310100559.16a2e ec8@posting.goo gle.com...[color=blue]
    > 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?[/color]


    Comment

    • Chris Soulsby

      #3
      Re: AxWebBrowser and JavaScript,

      Its the onclick event the <A onclick="javasc ript:Toggle(thi s)">

      Then in the scripting bit:

      function Toggle(node)
      {
      ...
      }

      "Gordon Truslove" <Gordon.Truslov e@QCL-Solutions.com> wrote in message
      news:O0GKWczjDH A.2512@TK2MSFTN GP09.phx.gbl...[color=blue]
      > What's in the click event?
      >
      > "Chris Soulsby" <chris.soulsby@ sysinx.com> wrote in message
      > news:860668f9.0 310100559.16a2e ec8@posting.goo gle.com...[color=green]
      > > 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?[/color]
      >
      >[/color]


      Comment

      • Gordon Truslove

        #4
        Re: AxWebBrowser and JavaScript,

        Not totally sure what you're doing but:
        try this...

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

        you can also run javascript in the browser from a c# app by doing this..
        el.location = "javascript:"+S omeScipt;

        "Chris Soulsby" <chris.soulsby@ sysinx.com> wrote in message
        news:OQkrPszjDH A.2244@TK2MSFTN GP12.phx.gbl...[color=blue]
        > Its the onclick event the <A onclick="javasc ript:Toggle(thi s)">
        >
        > Then in the scripting bit:
        >
        > function Toggle(node)
        > {
        > ...
        > }
        >
        > "Gordon Truslove" <Gordon.Truslov e@QCL-Solutions.com> wrote in message
        > news:O0GKWczjDH A.2512@TK2MSFTN GP09.phx.gbl...[color=green]
        > > What's in the click event?
        > >
        > > "Chris Soulsby" <chris.soulsby@ sysinx.com> wrote in message
        > > news:860668f9.0 310100559.16a2e ec8@posting.goo gle.com...[color=darkred]
        > > > 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?[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Chris Soulsby

          #5
          Re: AxWebBrowser and JavaScript,

          I've solved the problem :-)

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

          mshtml.IHTMLEle ment oIHTMLElement = null;
          mshtml.IHTMLDoc ument2 oIHTMLDocument2 =
          (mshtml.IHTMLDo cument2)this.Do cument;
          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.IHTMLDoc ument2 oIHTMLDocument2 =
          (mshtml.IHTMLDo cument2)this.Do cument;
          oIHTMLDocument2 .write(strHtml) ;

          Thanks for all the help.

          Chris



          "Chris Soulsby" <chris.soulsby@ sysinx.com> wrote in message
          news:860668f9.0 310100559.16a2e ec8@posting.goo gle.com...[color=blue]
          > 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?[/color]


          Comment

          Working...